In bash shell ls can use a logical OR functionality through (of course I could also do ls name1 name2 but my true examples are more complicated):

ls @(name1|name2)

Is there a way to do this using find?

My naive implementation:

find . -maxdepth 1 -name @("name1"|"name2") 

doesn't work (it just outputs nothing)

  • 4
    Did you read the OPERATORS section of the find manpage? Jul 1, 2015 at 12:44

2 Answers 2


You can use -o for logical OR. Beware however that all find predicates have logical values, so you'll usually need to group ORed things together with parens. And since parens also have a meaning to the shell, you'll also need to escape them:

find /some/dir -maxdepth 1 \( -name '*.c' -o -name '*.h' \) -print

To answer your question, you can use -o option:

   expr1 -o expr2
          Or; expr2 is not evaluated if expr1 is true.

   expr1 -or expr2
          Same as expr1 -o expr2, but not POSIX compliant.

like this:

$ find . -maxdepth 1 -name "name1" -o -name "name2"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .