mv 命令的语法格式如下:
[root@bogon ~]# mv [选项] 源文件 目标文件
其中 [] 括起来的部分为可选参数,可以忽略。
mv 命令的选项及功能如表 1 所示。
选 项 | 功 能 |
---|---|
-f | 强制覆盖,如果目标文件已经存在,则不询问,直接强制覆盖 |
-i | 交互移动,如果目标文件已经存在,则询问用户是否覆盖(默认选项) |
-n | 如果目标文件已经存在,则不会覆盖移动,而且不询问用户 |
-v | 显示文件或目录的移动过程 |
-u | 若目标文件已经存在,但两者相比,源文件更新,则会对目标文件进行升级 |
【例 1】mv 命令对文件重命名。
[root@bogon test]# ls test1 [root@bogon test]# mv test1 test [root@bogon test]# ls test [root@bogon test]#
可以看到,test 目录下仅有一个 test1 文件,借助 mv 命令,我们可以将该文件冲命令为 test。
【例 2】mv 移动文件或目录。
[root@bogon test]# pwd /root/test [root@bogon test]# cd .. [root@bogon ~]# ls Documents Videos demo [root@bogon ~]# mv /root/test demo [root@bogon ~]# cd demo [root@bogon demo]# ls test [root@bogon demo]# cd test [root@bogon test]# ls test [root@bogon test]#
大家关于Linux中mv的命令还有什么想补充的吗?可以在评论区留言啊。
为各位朋友分享的相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多