vivek vivek - 1 year ago 72
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 Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download