Welcome to Linux Forums!

With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.

Linux Forum ArticlesLinux ForumsLinux Forum DownloadsLinux Hosts
Home|Register|FAQ|Member List|Calendar|Unanswered Posts|Forum Rules|Today's Posts|Advanced Search|
SEARCH FOR IN
Go Back   Linux Forums > Your Distro > Gentoo Linux Help
Reload this Page Skip duplicate files with copy (cp)
Linux Forums
Linux Forums
Welcome To The Linux Forums!
Welcome to Linux Forums. We pride ourselves in being one of the largest Linux communities on the web, we encourage you to REGISTER on our forums and participate in the community. There are over 150,000 members ready to answer your questions. JOINING US today will allow you to make new posts, get support, send messages to other members and submit downloads to our downloads directory and many other great features!

Gentoo Linux Help For help and discussion related to Gentoo Linux

Reply
 
Thread Tools Display Modes
Old 01-21-2008   #1 (permalink)
tomchilton
Just Joined!
 
Join Date: Jan 2008
Posts: 2
Skip duplicate files with copy (cp)

Hi,

I am trying to copy a load of files from an old computer to my Gentoo box. Over a wireless (b) network this has been slightly flakey but I'm pretty much there.
What I would like to do now is run the copy command again, but have it automatically skip the files that already exist. Thus far I have been using the -i interactive switch but then I have to press enter to skip each duplicate.

Can anyone suggest an elegant alternative?

Thanks
Tom
tomchilton is offline   Reply With Quote
Old 01-21-2008   #2 (permalink)
sdimhoff
Linux Newbie
 
sdimhoff's Avatar
 
Join Date: Jan 2007
Posts: 115
This isn't as elegant as I think you are looking for, but could you use the update flag?

cp -u

--update
copy only when the SOURCE file is newer than the destination
file or when the destination file is missing


You would have to be a bit careful just because it just looks at the timestamp, but will at least you won't have to sit in front of the terminal and babysit the copy.


----

I also found this but have never used it. However, it may be what you are looking for.

`--reply=HOW'
*Deprecated: to be removed in 2008.*
Using `--reply=yes' makes `cp' act as if `yes' were given as a
response to every prompt about a destination file. That
effectively cancels any preceding `--interactive' or `-i' option.
Specify `--reply=no' to make `cp' act as if `no' were given as a
response to every prompt about a destination file. Specify
`--reply=query' to make `cp' prompt the user about each existing
destination file.


What you would do (I think) is do cp -i --reply=no

That way, it will ask if you want to overwrite the file and automatically say "no." Check your version and give it a test run as this option will be removed very soon!

Last edited by sdimhoff; 01-21-2008 at 01:51 PM. Reason: Found a better way
sdimhoff is offline   Reply With Quote
Old 01-24-2008   #3 (permalink)
tomchilton
Just Joined!
 
Join Date: Jan 2008
Posts: 2
hi,

That's really useful thanks. I had thought of the update option, but it hadn't worked for me in the past. I now realise my clock was set wrong so in the future that should work just fine.
seems like a shame to get rid of the --reply option as this was maybe more appropriate for my needs as I was copying music and so am not really bothered by the date stamp.

Cheers
tom
tomchilton is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wireless Not Connecting syed_salman Debian Linux Help 3 01-11-2008 04:07 AM
Bash Copy Script Based on Recent Files Andrew Richards Linux Programming & Scripting 2 08-24-2007 01:59 PM
How to copy two files into one? LinuxUserToBe Linux Newbie 5 06-21-2006 02:40 PM
Copy files from a SVN repository mix- Linux Programming & Scripting 1 05-10-2006 11:14 PM
Java errors... adamdaughterson Misc 2 12-10-2003 05:18 PM




All times are GMT. The time now is 02:09 AM.




© 2000 - 2008 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.0.0