Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

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


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?

Old 06-18-2007, 05:01 AM   #2
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:
find / -name *baa* -exec "cp {} /home/baa/"
Old 06-18-2007, 05:42 AM   #3
Senior Member
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Originally Posted by Zmyrgel
Yes it should be something like this:
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:
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
LQ Newbie
Registered: Apr 2007
Posts: 10

Original Poster
Rep: Reputation: 0

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

very much appreciated


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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:49 AM.

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