On 07/18/2015 at 07:18 AM, Wilko Fokken wrote: > On Thu, Jul 16, 2015 at 08:23:13AM -0400, Haines Brown wrote: > >> Sorry for this elementary question. I want to do sequential copies with >> a command like this: $ cp --backup=t file .../destination/file. When >> periodically run it produces file, file.~1~, file.~2~, etc. >> >> How do I get rid of the "~" so that the backups are file.1, file.2, >> etc.? > > If you are familiar with shell scripts, you can use a 'for' loop: > ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ > for i in 1 2 3 ; do > mv file.~${i}~ file.${i} > done > ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ > > You don't have to put each number into the 'for' loop yourself; > with e.g. 17 files, you can write: > > for i in `seq 1 17`; do > ... > done
Or just try mmv, from the package of the same name. mmv "file.~*~' "file.#1" should do it in this case. None of this really addresses the original question as I understood it, which was how to tell cp to create its backup filenames with a different naming pattern - but as far as I've been able to discover there doesn't seem to be any way to do that, so workarounds like this are about the best that can be done. (Aside from possibly filing a feature request against coreutils upstream, anyway. But the odds of that going anywhere soon seem slim.) -- The Wanderer The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man. -- George Bernard Shaw
signature.asc
Description: OpenPGP digital signature