mv :改名或者变更文件存放位置

mv :改名或者变更文件存放位置

用法:
    mv [选项]... 源文件... 目录
    mv [选项]... -t 目录 源文件...
选项:
    -b :当目标文件存在时,先进行备份,在覆盖
    -f :强制覆盖
    -i :交互式,覆盖前询问

• mv :移动文件,默认-i

[root@host test]# ls
file1  file2  file3  file4  file5  time
[root@host test]# mv file* time
[root@host test]# ls
time
[root@host test]# cd time/
[root@host time]# ls
file1  file2  file3  file4  file5
[root@host test]# touch file1
[root@host test]# mv file1 atime/
mv:是否覆盖"atime/file1"? y

• mv file file2 :改名

[root@host test]# ls
time
[root@host test]# mv time atime
[root@host test]# ls
atime

• mv -b:目标文件存在时,先备份,在覆盖

[root@host test]# ls
atime
[root@host test]# touch file1
[root@host test]# echo "1234" > file1
[root@host test]# cd atime/
[root@host atime]# echo "5678" > file1
[root@host atime]# cd ..
[root@host test]# mv -b file1 atime/
mv:是否覆盖"atime/file1"? y
[root@host test]# cd atime/
[root@host atime]# ls
file1  file1~  file2  file3  file4  file5
[root@host atime]# cat file1
1234
[root@host atime]# cat file1
file1   file1~         #file1~就是移动之前atime/file1的备份文件
[root@host atime]# cat file1~
5678

• mv -f:强制覆盖

[root@host test]# touch file1
[root@host test]# echo "123456" > file1
[root@host test]# mv -f file1 atime/
[root@host test]# ls
atime
[root@host test]# cd atime/
[root@host atime]# ls
file1  file1~  file2  file3  file4  file5
[root@host atime]# cat file1
123456
[root@host atime]# cat file1~       #这个file1~是mv -b的没有删除
5678

• mv -t 路径 file:移动文件

[root@host test]# ls
atime
[root@host test]# touch file
[root@host test]# mv -t atime/ file
[root@host test]# ls
atime
[root@host test]# cd atime/
[root@host atime]# ls
file

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值