Recursively find files with a specific extension

My preference:

find . -name '*.jpg' -o -name '*.png' -print | grep Robert

Using find's -regex argument:

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

Or just using -name:

find . -name 'Robert.*' -a \( -name '*.cpp' -o -name '*.h' \)

find -name "*Robert*" \( -name "*.pdf" -o -name "*.jpg" \)

The -o repreents an OR condition and you can add as many as you wish within the braces. So this says to find all files containing the word "Robert" anywhere in their names and whose names end in either "pdf" or "jpg".


As an alternative to using -regex option on find, since the question is labeled bash, you can use the brace expansion mechanism:

eval find . -false "-o -name Robert".{jpg,pdf}

This q/a shows how to use find with regular expression: How to use regex with find command?

Pattern could be something like

'^Robert\\.\\(h|cgg\\)$'