The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
list the files but exclude the files in subdirectories shyjuezy UNIX for Dummies Questions & Answers 8 10-15-2008 10:42 AM
Listing subdirectories and files senthil_is Shell Programming and Scripting 1 05-24-2008 04:38 AM
Listing all files in all subdirectories kuciauskas UNIX for Dummies Questions & Answers 3 02-01-2008 02:45 PM
tar subdirectories for specific files ronald_brayan UNIX for Advanced & Expert Users 4 10-12-2006 02:53 AM
Searching files within subdirectories jalvarez UNIX for Dummies Questions & Answers 1 09-08-2003 01:12 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 10-03-2005
Registered User
 

Join Date: Sep 2005
Posts: 6
copy certain files from subdirectories

Hi all,
I'd very grateful for some help with the following.

I have a variable number of subdirectories each of which contain a uniquely names results file of the form Results*.dat.

I would like to search through all subdirectories and copy out these results file to another directory so that I can combine them, diff them etc.

find . -name Results*.dat

will find all the files for me. How should I pass this to cp (copy)?

Thanks,
E
Reply With Quote
Forum Sponsor
  #2  
Old 10-03-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,683
Code:
find . -name Results*.dat -exec cp {} /destination/dir \;
Read the man page for -exec

vino
Reply With Quote
  #3  
Old 10-05-2005
Registered User
 

Join Date: Sep 2005
Posts: 6
Thanks very much
Reply With Quote
  #4  
Old 10-06-2005
Registered User
 

Join Date: Jun 2005
Location: Ireland
Posts: 61
find dir/ -name 'Results*.dat' | xargs cp -a --target-directory=/dest/dir --parents
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:57 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0