Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 12-02-2004, 01:43 AM   #1
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?

Old 12-02-2004, 04:08 AM   #2
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

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

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

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

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

Rep: Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393
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, 01:15 AM   #7
Senior Member
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 13.1
Posts: 1,324

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


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

All times are GMT -5. The time now is 05:48 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration