@laks wrote:
lets say we have empty directory 'i'
$ ls i
We want to move a file named 'a' into that directory.
$ mv a i/
Simple so far. later sometime, a new file created with same name 'a'.
$ touch a
We want to ensure, that if the target directory already contains similar filename,
instead of overwriting, we want to backup old file and create this new file.
mv has an option '--backup' to do that.
$ mv --backup="numbered" a i/
$ touch a $ mv --backup="numbered" a i/
Can you guess the expected result? its
$ ls i a a.~1~ a.~2~
It works at directory level too:
mkdir j touch j/{a,b,c} mv --backup="numbered" j/* i touch j/{a,b,c} mv --backup="numbered" j/* i
Finally the directory looks like
$ls i a a.~1~ a.~2~ a.~3~ a.~4~ b b.~1~ c c.~1~
Posts: 1
Participants: 1