How to use multiple filename search patterns with Linux find

Unix/Linux find FAQ: How do I use the Linux find command to find multiple filename extensions (patterns) with one command?

Problem

You want to use the Linux find command to search for multiple filename types (or patterns). You know you can run the find command several times, one for each filename extension you’re looking for, but there must be a way to search for multiple filenames at one time.

Solution

Yes, you can search for multiple filename extensions/patterns with one Unix find command. The syntax is a little obscure and hard to find, but here are several examples.

First, here’s a find command example that searches for all files beneath the current directory that end with the filename extensions .pl or .pm:

find . -type f \( -name "*.pl" -o -name "*.pm" \)

Here’s a second find command example that searches for all files beneath the current directory that end with the filename extensions .java, .xml, or .html:

find . -type f \( -name "*.java" -o -name "*.xml" -o -name "*.html" \)