The MV in Linux is the meaning of move
The general form of the command:
MV [option] parameter 1 parameter 2
Options:
-B If the same file name already exists, make a backup before overwriting
-F Force Overwrite if the same file name already exists and the user does not have write permission
-I prompts the user for confirmation before overwriting if the same file name already exists
-U compares the original file with the target file modification time and does not overwrite if the target file is newer
-V lists all files that were moved or renamed
According to the difference between parameter 1 and parameter 2, can be divided into three types:
1.MV [Options] File 1 file 2 this way for overwriting and renaming files
2.mv[Options] File 1 directory 2 this way for file-to-directory movement
3.mv[Options] Directory 1 directory 2 this way for directory overrides and renaming
Example:
For Form 1, there is a test1 file in the TestDir directory, and there is no Test2 file.
Rename file 1 to file 2
For Form 1, in the TestDir directory, test1 and test2 are present, test2 are overwritten as Test1
For Form 2, the Test1 file and the Newdir directory exist in the TestDir directory, and the Newdir directory is empty, then the implementation file is moved to the directory
The Test1 file box Newdir directory exists in the TestDir directory, and the Test1 file exists in the Newdir directory, then the implementation newdir
The directory is overwritten with the new Test1 file, if the value of Test1 is 1, and the value of test1 file in Newdir is 2, then MV Test1 Newdir
The value of test1 in the Newdir directory is 1.
For Form 3, if two command parameters are directories, then if the parameter 1 is an existing directory and the parameter 2 is a directory that does not exist, then the implementation will be directory 1
Renamed to Directory 2, if both directory 1 and directory 2 exist, then directory overrides are implemented.
Reprint please specify: Xiao Liu
The MV of Linux commands