Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grep and copy

Status
Not open for further replies.

inunix

Technical User
Jul 30, 2002
53
US
Hi,

Is there a easy way to select files based on some pattern from a directory and copy the respective files to another directory.?

any easy way to do this...

I've somehting but not sure this will work.

find . -name "mypattern" *.txt -exec cp {} .
Will the above command work?

Any help would be appreciated.

Thanks

 
Is the pattern contained within the file, or is it a pattern within the file name?
 
pattern contained within the file...

Thanks..
I think i got the solution..

here it is
grep -l 'foreach' *.txt |xargs -i cp "{}" tmp1/

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top