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:
find . -name '*.c' -o -name '*.h' -o -name '*.cc'
Edit
To do this with a single pattern you'll want a regex:
find . -regextype posix-extended -regex '.*\.(c|h|cc)'
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 by find. But there's nothing wrong with the sort of command building/chaining in my first example. It's how find is intended to be used.
If you really want to use a regex then
find -regex "\(.*\.[hc]\|.*\.cc\)"
should do the trick but the more normal way to do this is to use -o as already demonstrated.