[linux] 循序渐进学运维-mv
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了[linux] 循序渐进学运维-mv,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4043字,纯文字阅读大概需要6分钟。
内容图文
![[linux] 循序渐进学运维-mv](/upload/InfoBanner/zyjiaocheng/924/9cadcbf8de1446da9020f1f7f78e8f41.jpg)
文章目录
mv命令介绍
功能:
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
重命名或者移动文件名字
常用选项:
-b 目标文件存在创建备份,备份文件是"文件名后跟~"
-u 当源文件比目的文件修改时间新时才移动
-v 显示移动信息
–help的内容如下:
Usage: mv [OPTION]... [-T] SOURCE DEST or: mv [OPTION]... SOURCE... DIRECTORY or: mv [OPTION]... -t DIRECTORY SOURCE... Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY. Mandatory arguments to long options are mandatory for short options too. --backup[=CONTROL] make a backup of each existing destination file -b like --backup but does not accept an argument -f, --force do not prompt before overwriting -i, --interactive prompt before overwrite -n, --no-clobber do not overwrite an existing fileIf you specify more than one of -i, -f, -n, only the final one takes effect. --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 file -u, --update move only when the SOURCE file is newer than the destination file or when the destination file is missing -v, --verbose explain what is being done --help display this help and exit --version output version information and exitThe backup suffix is `~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through the VERSION_CONTROL environment variable. Here are the values: 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 Report mv bugs to bug-coreutils@gnu.org GNU coreutils home page: <http://www.gnu.org/software/coreutils/> General help using GNU software: <http://www.gnu.org/gethelp/> For complete documentation, run: info coreutils 'mv invocation'
案例:
1. -b 如果要拷贝过去的文件夹下有目标文件,则加~
[root@zmedu ~]# mkdir test1 test2[root@zmedu ~]# touch test1/a.txt[root@zmedu ~]# touch test1/b.txt[root@zmedu ~]# touch test/a.txttouch: cannot touch `test/a.txt': No such file or directory[root@zmedu ~]# touch test2/a.txt[root@zmedu ~]# mv -b test2/a.txt test1 mv: overwrite `test1/a.txt'? y[root@zmedu ~]# ls test1/a.txt a.txt~ b.txt[root@zmedu ~]# 可以看到多了一个a.txt,而且第二个a.txt后面有~符号
2. -f 强制覆盖
[root@zmedu ~]# lstest1 test2[root@zmedu ~]# ll test1/total 0 -rw-r--r-- 1 root root 0 Nov 17 20:42 a.txt -rw-r--r-- 1 root root 0 Nov 17 20:42 a.txt~ -rw-r--r-- 1 root root 0 Nov 17 20:42 b.txt[root@zmedu ~]# ll test2/total 0 -rw-r--r-- 1 root root 0 Nov 17 20:48 a.txt[root@zmedu ~]# mv -f test2/a.txt test1/[root@zmedu ~]# ll test1/total 0 -rw-r--r-- 1 root root 0 Nov 17 20:48 a.txt -rw-r--r-- 1 root root 0 Nov 17 20:42 a.txt~ -rw-r--r-- 1 root root 0 Nov 17 20:42 b.txt[root@zmedu ~]#
3. -i:默认选项,当目标文件存在时,提示是否覆盖
[root@zmedu ~]# touch a.txt[root@zmedu ~]# lsa.txt test1 test2[root@zmedu ~]# mv -i a.txt test1/mv: overwrite `test1/a.txt'? y[root@zmedu ~]#
4. -n 如果文件存在则不覆盖
[root@zmedu ~]# lsa.txt test1 test2[root@zmedu ~]# mv -vn a.txt test1/[root@zmedu ~]# ll test1/total 0 -rw-r--r-- 1 root root 0 Nov 17 20:51 a.txt -rw-r--r-- 1 root root 0 Nov 17 20:42 a.txt~ -rw-r--r-- 1 root root 0 Nov 17 20:42 b.txt
5. -v 显示详细信息
[root@zmedu ~]# mv -v a.txt test1/mv: overwrite `test1/a.txt'? y`a.txt' -> `test1/a.txt'[root@zmedu ~]#
总结:
学习的过程中多用 --help是必要的 ,如果有不懂的参数,直接–help一下,英文的解释会更清晰明了。
内容总结
以上是互联网集市为您收集整理的[linux] 循序渐进学运维-mv全部内容,希望文章能够帮你解决[linux] 循序渐进学运维-mv所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。
来源:【匿名】