Moving or renaming files can be accomplished with the mv command.
Synopsis: mv [OPTION]... [-T] SOURCE DEST
mv [OPTION]... SOURCE... DIRECTORY
mv [OPTION]... -t DIRECTORY SOURCE...
Below is a list of the options that can be used with the mv command. You can use more than one at a time by stacking them.
|--backup[=CONTROL]||Make a backup of each existing destination file.|
|-b||Like --backup but does not accept an argument.|
|-S||-suffix=SUFFIX||Override the usual backup suffix./td>|
|-t||--target-directory=DIRECTORY||Move all SOURCE arguments into DIRECTORY|
|-T||--no-target-directory||Treat DEST as a normal file.|
|-u||--update||Performs the move only when the SOURCE file is newer than the destination file or when the destination file is missing.|
|-v||--verbose||Displays an explanation of what is being done.|
|--help||Display this help and exit.|
|--version||Output version information and exit.|
Renaming a file When renaming a file in the same directory, no directory information is included. The only parameters needed are the old and new file names. Below we rename the original oldtext.txt file to newtext.txt.
Moving a file to another directory In this example we are moving the file somefile.txt to a subfolder named level2. The second parameter includes the relative path as well as the file name.
Moving to another folder while renaming This example is much like the example above, but we are also renaming the file as it is moved. The second parameter includes the destination folder as well as the new name.