vivek vivek - 3 months ago 17
Perl Question

copy without overwrite and preserve existing files with extended name

i need to copy files with specific extensions. but the problem is there are multiple files with same file name.i dont want to overwrite them and store as copy like file _1,file_2 etc. when i tried using unix command line the files are overwitten though i used cp -n.
is there any way i can do this task using command line or perl ?
the command i used was


find -L . -name "*.txt" -exec cp -n {} -t ~/destination

Answer

You can also use the cp --backup=numbered option.

Comments