每天一个linux命令(7),每天一个linux命令:mv(7)

文件覆盖前做简单备份

命令: **mv -b myFile1 myFile2 ** [root@VM_0_9_centos test]# ll

total 0

-rw-r--r-- 1 root root 0 Oct 27 10:14 myFile1

-rw-r--r-- 1 root root 0 Oct 27 10:05 myFile2

[root@VM_0_9_centos test]# mv -b myFile1 myFile2

mv: overwrite ?.yFile2?. y

[root@VM_0_9_centos test]# ll

total 0

-rw-r--r-- 1 root root 0 Oct 27 10:14 myFile2

-rw-r--r-- 1 root root 0 Oct 27 10:05 myFile2~

-b 不接受参数,mv会去读取环境变量VERSION_CONTROL来作为备份策略。

--backup该选项指定如果目标文件存在时的动作,共有四种备份策略:

1.CONTROL=none或off : 不备份。

2.CONTROL=numbered或t:数字编号的备份

3.CONTROL=existing或nil:如果存在以数字编号的备份,则继续编号备份m+1...n:

执行mv操作前已存在以数字编号的文件log2.txt.~1~,那么再次执行将产生log2.txt~2~,以次类推。如果之前没有以数字编号的文件,则使用下面讲到的简单备份。

4.CONTROL=simple或never:使用简单备份:在被覆盖前进行了简单备份,简单备份只能有一份,再次被覆盖时,简单备份也会被覆盖。 [root@VM_0_9_centos test]# mv -b --backup=numbered myFile2

mv: missing destination file operand after ?.yFile2?

Try 'mv --help' for more information.

[root@VM_0_9_centos test]# mv -b --backup=numbered myFile1 myFile2

mv: overwrite ?.yFile2?. y

[root@VM_0_9_centos test]# ll

total 0

-rw-r--r-- 1 root root 0 Oct 27 10:27 myFile2

-rw-r--r-- 1 root root 0 Oct 27 10:16 myFile2.~1~

[root@VM_0_9_centos test]#

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值