When using find
what is the correct format to say "Find files that end in .jpg OR .png"?
Is it as simple as using the |
operator/character?
find -iname "*.jpg|*.png"
When using find
what is the correct format to say "Find files that end in .jpg OR .png"?
Is it as simple as using the |
operator/character?
find -iname "*.jpg|*.png"
No.
You need to use -o
(OR) in find
like:
find \( -iname '*.jpg' -o -iname '*.png' \)
Your one would be close to correct if you are matching Regex:
find -iregex ".*\(jpg\|png\)"
Or using extended Regex:
find -regextype posix-extended -iregex ".*(jpg|png)"
-regextype egrep
also gives you extended regular expressions with GNU extensions (like \w
and \b
and {n,m}
intervals) and is shorter to type. see pinfo find --node 'Regular Expressions'
– cas
May 10 '16 at 01:27
find --version
says 4.7.0-git). I've been using -regextype awk
until recently, but that doesn't support the gnu extensions.
– cas
May 10 '16 at 04:28