View Single Post
  #1   (View Single Post)  
Old 28th May 2011
Daffy Daffy is offline
Fdisk Soldier
 
Join Date: Jun 2010
Posts: 73
Default Pipe grep to copy files based on name.

I just finished restoring some files from a friend's hard disk. All files are now into a folder and I need to transfer some of them.

While it's easy to copy files with a certain extension, I cannot understand how I can copy them using the filenames.

To select files to copy based on the extension, I just use cp *.(extension) /destination/folder/.

To list items based in name, I used
Code:
ls | grep name\ to\ search
I think that it will be something like
Code:
cp | grep name\ to\ search
but where do I specify the destination folder?

How do I pipe grep to cp to transfer files based on name?
Reply With Quote