find . -name "*.[hc]|*.cc"
The above doesn't work,why?
UPDATE
How do I find these 3 kinds of files with a single pattern?
find . -name "*.[hc]|*.cc"
The above doesn't work,why?
UPDATE
How do I find these 3 kinds of files with a single pattern?
It doesn't work because
-name
expects a shell pattern. You can use-regex
instead, or just assemble your pattern like so:Edit
To do this with a single pattern you'll want a regex:
You could do it with the default emacs regexes, I'm sure; I don't use them or know the main differences so I picked the one I know.
If you really want to use a single shellglob, you're out of luck: the only syntax for multiple strings is
{a,b}
, and this is not supported byfind
. But there's nothing wrong with the sort of command building/chaining in my first example. It's howfind
is intended to be used.If you really want to use a regex then
should do the trick but the more normal way to do this is to use -o as already demonstrated.