University Crest

[wlug] how to find files with multiple suffixes

 
wlug archive index About the wlug list Mailing lists home
To The University of Waikato HomepageWaikato Home > Waikato Mailing Lists > wlug Info > wlug archives
Glenn Ramsey glenn@c...
Tue Apr 20 21:05:28 NZST 2004


How do I find files having either of several extensions?

Eg this finds all .c and .h files

$find . -name '*.[ch]'

but what if I want to find all .cpp and .h files?

I guess I need a grouping operator in the pattern but I can't figure out 
what it is.

I've looked in the man page and Google and tried a few things, also 
tried the -regex switch instead of -name but couldn't get it to work.

Eg this doesn't find anything

$find . -regex '.*\.(cpp|h)'

I suspect the answer is really simple. Any ideas what I'm doing wrong?

g

-- 
Glenn Ramsey <glenn@c...> 07 8627077
http://www.componic.co.nz




More information about the wlug mailing list
NOTICE: This is an archive of a public mailing list. The University of Waikato is not responsible for its contents.

The University of Waikato - Te Whare Wananga o Waikato