简体   繁体   English

更改bash文件备份的后缀

[英]Changing suffix on bash file backup

I have been trying to change the suffix on my backup files using the --suffix function but I'm not quite sure how to do it. 我一直在尝试使用--suffix函数更改备份文件上的后缀,但是我不确定该怎么做。 Currently this line of code 目前这行代码

find ./$1 -name "IMG_****.JPG" -exec cp --backup=t {} ./$2 \;

searches the first command line argument directory for images in the IMG_****.JPG format and copies them to the directory entered second, making copies of any files with duplicate names and adding the =t suffix to the end giving IMG_****.JPG.~1~ etc. Instead of .~1~ I would like to add something like .JPG , any ideas on how to use the --suffix to do this? 在第一个命令行参数目录中搜索IMG_****.JPG格式的图像,然后将其复制到第二个输入的目录中,以任何名称重复的文件进行复制,并在末尾添加=t后缀,以提供IMG_****.JPG.~1~.~1~我想添加.JPG而不是.JPG ,关于如何使用--suffix执行此操作的任何想法?

Read the man page : 阅读手册页

The backup suffix is ' ~ ', unless set with --suffix or SIMPLE_BACKUP_SUFFIX . 备份后缀为“ ~ ”,除非使用--suffixSIMPLE_BACKUP_SUFFIX设置。

It should be pretty obvious from this sentence that supplying --suffix is equivalent to setting SIMPLE_BACKUP_SUFFIX , which as its name suggests only applies to simple backups (ie, --backup=simple or --backup=never ). 从这句话中可以很明显地看出,提供--suffix等效于设置SIMPLE_BACKUP_SUFFIX ,顾名思义,该设置仅适用于简单备份(即--backup=simple--backup=never )。 Eg, 例如,

> touch src dst
> cp --backup=simple --suffix=.bak src dst
> ls src* dst*
dst  dst.bak  src

However, you are requesting numbered backups through --backup=t , so the suffixes you will get will always be .~1~ , .~2~ , etc., unaffected by --suffix . 但是,您请求通过编号备份--backup=t ,所以你会得到后缀总是会.~1~ .~2~等,通过影响--suffix

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM