[X-Unix] cp question

Eugene list-themacintoshguy at fsck.net
Thu Feb 24 14:39:07 PST 2005


On Thu, Feb 24, 2005 at 04:01:01PM -0600, Russell McGaha wrote:
: 
: Folks;
: 	I've got a question about how to only copy certain files of a folder 
: [more accurately to not copy].
: 	I've a 10.2.8 system [so I'll be using tsch] that I need to copy the 
: files in one director to another directory; this is no problem, BUT I 
: need to EXCLUDE a couple of files; this is a problem.  how can I 'walk 
: a directory and look at the next file to be copied and exclude it if 
: necessary'?
:  my source directory will look something like 
: this:'/Backup-HD/DailBckups/DayOfWeek-Evening/'; destination 
: '/FolderToCopyTo/'.  I'm currently ending the source with a wild-card 
: '*' to copy everything.
: 	Any suggestions on how to EXCLUDE certain files that I know the 
: 	exact names of?

Not with cp alone.  You'd have to do something more exotic, e.g.:

	find /Backup-HD/DailBckups/DayOfWeek-Evening/ -type f \! -name "not_this_file.txt" \! -name "not_this_file2.mpg" -exec cp {} /FolderToCopyTo/ \;

Note, solution above is not guaranteed to be safe for all Mac filenames.


-- 
Eugene Lee
http://www.coxar.pwp.blueyonder.co.uk/


More information about the X-Unix mailing list