Previous Section  < Day Day Up >  Next Section

mv—moves or renames files


mv [ –f ] [ –i ] filename1 [ filename2 ...] target


The mv command moves a source filename to a target filename. The filename and the target may not have the same name. If target is not a directory, only one file may be specified before it; if it is a directory, more than one file may be specified. If target does not exist, mv creates a file named target. If target exists and is not a directory, its contents are overwritten. If target is a directory, the file(s) are moved to that directory.

Example A.38.

1   mv file1 newname

2   mv -i test1 test2 train


EXPLANATION

  1. Renames file1 to newname. If newname exists its contents are overwritten.

  2. Moves files test1 and test2 to the train directory. The –i switch is for interactive mode, meaning it asks before moving the files.

    Previous Section  < Day Day Up >  Next Section