Actually, searching for multiple patterns should be a trivial task. Find provides a -o
operator (and many others) that lets you combine multiple expressions.
A simple Example: You want to find all files in the current directory whose filename extension are either .c
or .h
$ find . \( -name "*.c" -o -name "*.h" \) -print
This is not limited to the -name
test but can be combined with any other test (like -perm
, -size
, -type
, etc.)
But Careful! You need to quote patterns that contain metacharacters (such as * in the example above). Singe quotes work as well as double quotes. The braces surrounding the expression have to be escaped, too. And watch those spaces right before and after the braces, they’re essential.
See also find manpage, GNU find documentation
There needs to be simpler way to thumbs-up random hacking blog posts than having to write a whole WP comment for them :>
@Leho Kraav
You asked for it, you got it!