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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
12-02-2004, 12:43 AM
|
#1
|
Member
Registered: Jun 2004
Posts: 36
Rep:
|
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
|
|
|
12-02-2004, 03:08 AM
|
#2
|
Senior Member
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897
Rep:
|
find . \( -name "*.c" -o -name "*.h" -o -name "*.sc" -o -name "*.ini" \) -print
Yves.
|
|
1 members found this post helpful.
|
12-02-2004, 08:14 AM
|
#3
|
Member
Registered: Jun 2004
Posts: 36
Original Poster
Rep:
|
Thanks friend. You solved my problem
|
|
|
12-14-2010, 09:10 AM
|
#4
|
LQ Newbie
Registered: Dec 2010
Posts: 4
Rep:
|
thanks, that was really helpful..
|
|
|
12-14-2010, 01:54 PM
|
#5
|
Member
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 709
|
Code:
find | egrep '\.(c|h|sc|ini)$'
|
|
|
12-14-2010, 04:46 PM
|
#6
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,253
|
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.
|
|
|
12-15-2010, 12:15 AM
|
#7
|
Senior Member
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339
|
There is also -regex in find. So it's possible to have both.
|
|
|
All times are GMT -5. The time now is 07:29 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|