LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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 01-29-2009, 09:32 AM   #1
thok
LQ Newbie
 
Registered: Oct 2007
Distribution: CentOS 4.x
Posts: 12

Rep: Reputation: 0
Single find command to find multiple files?


i want to find multiple files with a single find command

for example i want to find files with foo and bar in their name on my webserver... how can i do it with a single find command?

Last edited by Tinkster; 01-29-2009 at 03:08 PM. Reason: keep LQ off R18 rating ...
 
Old 01-29-2009, 09:50 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,488

Rep: Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956
You can use two different patterns using two -name tests separated by a logical OR. The syntax is highlighted in red below:
Code:
find . \( -name \*foo\* -o -name \*bar\* \)

Last edited by Tinkster; 01-29-2009 at 03:08 PM. Reason: keep LQ off R18 rating ...
 
Old 01-29-2009, 10:35 AM   #3
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 5.4, Mac OS 10.4 (tiger)
Posts: 1,005

Rep: Reputation: 79
next time you need an example. please just say foo and bar... I dread it when I see lines I have in script files in... err nevermind .
 
Old 01-29-2009, 10:39 AM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,488

Rep: Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956
Sorry... erroneous post.

Last edited by colucix; 01-29-2009 at 04:08 PM. Reason: Following directions by moderator.
 
Old 01-29-2009, 03:12 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,974
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Quote:
Originally Posted by r3sistance View Post
next time you need an example. please just say foo and bar... I dread it when I see lines I have in script files in... err nevermind .
I totally second this notion. Not that I'm that prudish, but
LQ is supposed to be accessible to underage folk, and we'd like
to keep the language clean.

For this reason I took the liberty to make the posts a bit
more in line with the general concept ;}


Cheers,
Tink
 
Old 01-29-2009, 04:07 PM   #6
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,488

Rep: Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956
Quote:
Originally Posted by Tinkster View Post
For this reason I took the liberty to make the posts a bit more in line with the general concept ;}
I agree. I'm very sorry... I should have thought about the underage audience.
 
Old 01-30-2009, 03:58 AM   #7
thok
LQ Newbie
 
Registered: Oct 2007
Distribution: CentOS 4.x
Posts: 12

Original Poster
Rep: Reputation: 0
sorry ... i actually explained the exact situation i needed this command for ... to search for illegal files on my webserver hosted by users.

Last edited by Tinkster; 01-31-2009 at 04:37 PM.
 
Old 01-31-2009, 04:45 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,974
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Well ... for future reference: if things you're looking for
may appear dodgy, please take the time to sanitise/anonymise
whatever you're looking for. Your example is easily enough
transformed back and forth to foo, bar, baz w/o too much hassle
or extraordinary cognitive effort.
 
  


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
linux find to find files with multiple patterns subu_s Programming 6 12-15-2010 12:15 AM
Using a single "Find" Command to find files bases on multiple criteria roboxooo Linux - Newbie 6 01-15-2009 04:13 AM
find command - multiple direcories ygloo Linux - General 3 08-25-2006 04:44 PM
Find command - multiple file types mrclisdue Linux - General 4 07-03-2006 03:48 AM
using multiple -exec commands in a single find command? Bluemilk Linux - Newbie 4 03-19-2006 10:46 AM


All times are GMT -5. The time now is 08:32 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration