mv命令主要是一个将文件移动到另外一个位置的命令,用于文件移动。
参数:
-f:覆盖文件,且不提示【--force】
-i:提示是否覆盖文件【--interactive】
-n:如果文件存在,则不移动【--no-clobber】
-u:仅当源文件新的时候进行覆盖SourceByrd's Weblog-https://note.t4x.org/rebuilding/mv-command-description/-b like --backup but does not accept an argument
--strip-trailing-slashes:remove any trailing slashes from each SOURCE argument
-S, --suffix=SUFFIX
override the usual backup suffix
-t, --target-directory=DIRECTORY
move all SOURCE arguments into DIRECTORY
-T, --no-target-directory
treat DEST as a normal fileSourceByrd's Weblog-https://note.t4x.org/rebuilding/mv-command-description/--backup[=CONTROL]
make a backup of each existing destination fileSourceByrd's Weblog-https://note.t4x.org/rebuilding/mv-command-description/none, off
never make backups (even if --backup is given)
numbered, t
make numbered backups
existing, nil
numbered if numbered backups exist, simple otherwise
simple, never
always make simple backups SourceByrd's Weblog-https://note.t4x.org/rebuilding/mv-command-description/
案例:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[root@localhost tmp]# tree -h . ├── [ 159] 2.sh ├── [ 159] 34.sh ├── [ 36K] test │ ├── [ 159] 2.sh │ └── [ 0] 34.sh └── [ 0] yum.log [root@localhost tmp]# mv -f 34.sh test/ #覆盖文件,且不提示 [root@localhost tmp]# ll test/ -lh -rw-r--r--. 1 root root 159 Oct 9 11:29 34.sh #文件已经修改为159大小 [root@localhost tmp]# mv -i 34.sh test/ #提示是否覆盖 mv: overwrite `test/34.sh'? n [root@localhost tmp]# >test/34.sh [root@localhost tmp]# mv -n 34.sh test/ #如果存在则不替换 [root@localhost tmp]# ll test/34.sh -lh -rw-r--r--. 1 root root 0 Oct 9 13:10 test/34.sh [root@localhost tmp]# ll ./34.sh -lh -rwxr-xr-x. 1 root root 159 Oct 9 13:10 ./34.sh [root@localhost tmp]# mv -u 34.sh test/ #源文件比替换的文件新,才替换,且提示替换,否则不替换,不管被替换的是否和源文件一样 |