LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
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
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:59 PM.

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
Open Source Consulting | Domain Registration