How to use “find” command with several conditions

findunix

This command will print the *.cpp filenames in the given directory:

find . -name "*.cpp" -print  

How can I print both *.cpp and *.h filenames?

Best Answer

Try this:

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

An example with more alternatives:

find -regex ".*\.\(cpp\|c\|h\|o\)$"
Related Question