LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-17-2003, 01:38 PM   #1
rtaft
Member
 
Registered: Aug 2003
Posts: 85

Rep: Reputation: 15
cp help


I'm trying to copy a directory recursively, to a location that may have some of the files already there. I want it to ignore the files that already exist. If I just use cp -R, I will have to manually type 'n' for each duplicate file, which I cannot do. If I use cp -Rf, it overwrites the ones already there. If I use cp -Ru, it overwrites the files that have an older date than the one being copied. Isn't there a simple "if it exists, don't copy"? IS there a script out there tha will provide me with this functionality?
 
Old 12-17-2003, 01:42 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Try using cp's --reply={yes,no,query} option.

PS: You don't mention the -i option. This must be aliased in some way, otherwise cp would overwrite the destination file without asking you.

cp -iR --reply=no <foo> <bar> would be the correct use if you want to make sure that destination files that excist are not overwritten.

cp -R --reply=no <foo> <bar> doesn't make too much sense, there will be no questions asked excisting files will be overwritten.

Last edited by druuna; 12-17-2003 at 01:49 PM.
 
Old 12-17-2003, 01:48 PM   #3
rtaft
Member
 
Registered: Aug 2003
Posts: 85

Original Poster
Rep: Reputation: 15
thanks, that works great
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration