LINUX-Frequently used commands
|mv command Display the contents of a file|
|mv [Option] [Moving source] [Destination]|
|The mv command moves the specified file to the specified directory.
When executing, the source and destination must be specified.
Also, if you use an alias for a file when you move it, the file will be renamed too.
Alternatively, you can simply rename the file if you specify it in the same directory.
|Frequently used options|
|-f Force overwriting of files with the same name if they already exist in the new location
-i If a file with the same name already exists at the destination, check to overwrite it.
-u If a file with the same name already exists at the destination, it will not be moved if the timestamp is the same or newer than the source file.
|Example: Moving files.|
|$ mv data.dat /tmp ← move data.dat to the /tmp directory|
|Example: Force overwriting of files with the same name in the new location|
|$ mv -f test.txt /tmp ← Force overwrite of test.txt to /tmp directory|
|Example: If a file with the same name exists at the destination, make sure it is overwritten.|
|$ mv -i test.txt /tmp/ ← Move test.txt to the /tmp directory, making sure it is overwritten|
|Example: If the destination file has the same or newer type stamp than the source file, it will not be moved.|
|$ mv -u /tmp/test.txt ./test.txt ← Perform the move with the option "-u"
← A blank line becomes one line.