Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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
ls | grep name\ to\ search
I think that it will be something like
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

cp, grep

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot copy large files to Flash Drive sharris FreeBSD General 6 30th July 2010 09:57 AM
Copy w/ active verification Weaseal FreeBSD General 4 5th February 2009 12:23 AM
How to copy FBSD installation from one which is already installed on a HDD? padmanabh FreeBSD Installation and Upgrading 2 7th October 2008 04:09 AM
how to copy a directory. bsdnewbie999 OpenBSD General 1 12th July 2008 02:36 PM
fstat | grep internet | grep -v -e '>' -e '<' mfaridi OpenBSD General 4 10th June 2008 09:58 PM

All times are GMT. The time now is 07:37 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick