LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-18-2007, 04:51 AM   #1
dbrmik
LQ Newbie
 
Registered: Apr 2007
Posts: 10

Rep: Reputation: 0
Using the find command with a pipe to copy


Hi

I want to be able to use the 'find' command to look for files containing a particular pattern (ignoring case) in their filenames ,then copy these to another directory.

I have not been able to get this to work. Is this possible?

Regards
 
Old 06-18-2007, 05:01 AM   #2
Zmyrgel
Senior Member
 
Registered: Dec 2005
Location: Finland
Distribution: Slackware, CentOS, RHEL, OpenBSD
Posts: 1,006

Rep: Reputation: 37
Yes it should be something like this:
Code:
find / -name *baa* -exec "cp {} /home/baa/"
 
Old 06-18-2007, 05:42 AM   #3
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by Zmyrgel
Yes it should be something like this:
Code:
find / -name *baa* -exec "cp {} /home/baa/"
To ignore the case, you'd want -iname, not -name. You also need to enclose the *baa* in quotes, otherwise the shell parses it rather than letting find expand the asterisks. The find command needs to be finished with \; at the end too, and finally, the quotes need to go around the {}, not the whole cp command:
Code:
find / -iname "*baa*" -exec cp "{}" /home/baa/ \;
I think

Last edited by pwc101; 06-18-2007 at 05:45 AM.
 
Old 06-18-2007, 06:08 AM   #4
dbrmik
LQ Newbie
 
Registered: Apr 2007
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks

pwc101 - works like a dream, thanks for the quick replies

very much appreciated
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
pipe find output to scp groundhog_killer Linux - Networking 2 02-14-2006 11:46 AM
kill command in a pipe bujecas Linux - General 1 02-02-2006 08:55 AM
how to pipe and parse output of a command learnfast Linux - Newbie 2 06-15-2005 05:55 AM
how to: a pipe command? youngstorm Linux - Newbie 2 02-02-2005 11:52 AM
Pipe command question satimis Linux - Newbie 8 01-07-2004 11:54 AM


All times are GMT -5. The time now is 05:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration