Tagged with: Linux source update source file name MV
Mv
1. Command Format
usage : MV [option] source file or directory destination file or directory
2. Command function
Depending on the second parameter type in the MV command (either the destination file or the destination directory), the MV command renames the file or moves it to a new directory. When the second parameter type is a file, the MV command completes the file rename, at which point the source file can only have one (or the source directory name), which renames the given source file or directory to the specified destination file name. When the second parameter is a directory name that already exists, the source file or directory parameter can have more than one, and the MV command moves the source files specified by each parameter to the destination directory. When you move a file across a file system, the MV copies the original file, and the link to the file is lost.
3 command parameters and instances
-B: Overwrite the previous backup if you need to overwrite the file.
-f:force mandatory Meaning, if the target file already exists, will not be asked and directly covered;
-I: If the target file (destination) already exists, you will be asked to overwrite it!
-U: If the target file already exists and source is newer, update (update)
  &NBSP, -t -- Target-directory=directory move all source arguments into directory, which is the target directory for the specified MV, This option applies when moving multiple source files to a directory, at which point the destination directory is before the source file is
Example 1 : File renaming
Command:
MV a.txt B.log
[[email protected] data]# cat C.txt This is a[[email protected] data]# mv C.txt b.log[[email protected] data]# cat B.logth IS is a[[email protected] data]# lltotal 4-rw-r--r--. 1 root root 06:12 b.log[[email protected] data]#
Example2:the filea. txt,b. txtMove to Directorytest3the.
command: mv A.txt b.txt test3/
[[Email protected] data]# mv A.txt b.txt test3/[[email protected] data]# lsb.log test3[[email protected] data]# LS/TESTT est/test1/test3/[[email protected] data]# ls/data/test3/a.txt b.txt[[email protected] data]#
This article is from the "Qin Xian son" blog, please make sure to keep this source http://youdong.blog.51cto.com/3562886/1718152
Linux Basic Command Learning MV (7)