Linux Command mv, linuxmv
Mv in linux means move.
The general form of this command:
Mv [Option] parameter 1 parameter 2
Option:
-B. If the same file name already exists, back up the file before overwriting.
-F if the same file name already exists and the user does not have the write permission, forcibly Overwrite
-I if the same file name already exists, prompt the user to confirm before Overwriting
-U: Compare the modification time of the original and target files. If the target file is newer, it will not be overwritten.
-V: list all moved or renamed files
Parameters 1 and 2 can be divided into three forms:
1. mv [Option] File 1 file 2 this method is used for file overwrite and rename
2. mv [Option] File 1 directory 2 this method is used to move files to directories
3. mv [Option] Directory 1 directory 2 this method is used for directory overwrite and rename
Example:
For format 1, The test1 file exists in the testdir directory, and the test2 file does not exist.
Rename file 1 to file 2.
For Form 1, testdir directory contains test1 and test2, then test2 is overwritten as test1
For Format 2, The testdir directory contains the test1 file and newdir directory. If the newdir directory is empty, the file will be moved to the directory.
The testdir directory contains the newdir directory in the test1 file box and the test1 file in the newdir directory.
The directory overwrites the new test1 file. If the value of test1 is 1, and the value of test1 in newdir is 2, after the mv test1 newdir
The value of test1 in the newdir directory is 1.
For Form 3, if both command parameters are directories, if parameter 1 is an existing Directory and parameter 2 is an existing Directory, implement directory 1
Rename directory 2. If both directory 1 and directory 2 exist, the directory overwrites.
Reprinted, please note: Xiao Liu