LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   linux find to find files with multiple patterns (http://www.linuxquestions.org/questions/programming-9/linux-find-to-find-files-with-multiple-patterns-261595/)

subu_s 12-02-2004 12:43 AM

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

theYinYeti 12-02-2004 03:08 AM

find . \( -name "*.c" -o -name "*.h" -o -name "*.sc" -o -name "*.ini" \) -print

Yves.

subu_s 12-02-2004 08:14 AM

Thanks friend. You solved my problem

thiyagi 12-14-2010 09:10 AM

thanks, that was really helpful..

firstfire 12-14-2010 01:54 PM

Code:

find | egrep '\.(c|h|sc|ini)$'

syg00 12-14-2010 04:46 PM

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.

Reuti 12-15-2010 12:15 AM

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


All times are GMT -5. The time now is 01:47 AM.