viavad
viavad

Reputation: 373

Or condition in find's regex expression

Why does it look up nothing when files are exist?

find ./ -regex '.*(jar|war)'

Upvotes: 0

Views: 66

Answers (1)

kbulgrien
kbulgrien

Reputation: 4508

See man find for information about supported syntax for regular expressions:

-regextype type
       Changes the regular expression syntax understood by  -regex  and
       -iregex tests which occur later on the command line.  Currently-
       implemented types are emacs (this is  the  default),  posix-awk,
       posix-basic, posix-egrep and posix-extended.

This works:

$ find . -regextype egrep -regex '(.*jar)|(.*war)'

To avoid using -regextype change the expression to an emacs regular expression:

$ find . -regex '.*\(jar\|war\)'

Upvotes: 2

Related Questions