LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-02-2004, 12:43 AM   #1
subu_s
Member
 
Registered: Jun 2004
Posts: 36

Rep: Reputation: 15
linux find to find files with multiple patterns


Hi friends,
How do I use linux 'find' to find different types of files?
I.e to fine "*.h", "*.c", "*.sc" all in one command.

I currently do something like this:-
find . -name "*.c" > out
find . -name "*.h" >> out
find . -name "*.sc" >> out
find . -name "*.ini" >> out

Any easy way out?

Regards,
Subu
 
Old 12-02-2004, 03:08 AM   #2
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 61
find . \( -name "*.c" -o -name "*.h" -o -name "*.sc" -o -name "*.ini" \) -print

Yves.
 
1 members found this post helpful.
Old 12-02-2004, 08:14 AM   #3
subu_s
Member
 
Registered: Jun 2004
Posts: 36

Original Poster
Rep: Reputation: 15
Thanks friend. You solved my problem
 
Old 12-14-2010, 09:10 AM   #4
thiyagi
LQ Newbie
 
Registered: Dec 2010
Posts: 4

Rep: Reputation: 0
thanks, that was really helpful..
 
Old 12-14-2010, 01:54 PM   #5
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 623

Rep: Reputation: 364Reputation: 364Reputation: 364Reputation: 364
Code:
find | egrep '\.(c|h|sc|ini)$'
 
Old 12-14-2010, 04:46 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,228

Rep: Reputation: 1019Reputation: 1019Reputation: 1019Reputation: 1019Reputation: 1019Reputation: 1019Reputation: 1019Reputation: 1019
Two tools when the first has options to do it all ?.
That regex could be (better) used with locate if updatedb is indeed up to date.
 
Old 12-15-2010, 12:15 AM   #7
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 11.4
Posts: 1,319

Rep: Reputation: 252Reputation: 252Reputation: 252
There is also -regex in find. So it's possible to have both.
 
  


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
Find/grep command to find matching files, print filename, then print matching content stefanlasiewski Programming 8 12-18-2013 05:36 PM
grep for multiple patterns???? lucastic Linux - Software 4 08-06-2010 06:07 PM
Help, help! How to find lines in between searched patterns? wujee Linux - Software 1 01-06-2005 02:52 PM
linux 'find' to find text files subu_s Programming 2 12-02-2004 02:56 AM
find and copy files into multiple directories avargas22 Linux - Newbie 2 04-01-2004 11:11 AM


All times are GMT -5. The time now is 11:15 PM.

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