How to list files with the FIND command?

The goal is to get the files with extension jpg and png, but to exclude in the path/name to the edit file and 200x200

If you don't use the extension it works:
$find /var/www/test -type f ! -regex ".*\(edit\|200x200\).*"

If you do not use a regular expression that works:
$find /var/www/test -type f ! -name "*.jpg" -o -name "*.png"

If you combine reget and a couple name, it displays this:
$find /var/www/test -type f ! -regex ".*\(edit\|200x200\).*" -name "*.jpg" -o -name "*.png"

How to be?
March 23rd 20 at 18:50
1 answer
March 23rd 20 at 18:52
Solution
$find /var/www/test -type f ! -regex ".*\(edit\|200x200\).*" -name "*.jpg" -o -name "*.png"

Operations in line conditions find have priorities, the priority "or" lower than the priority of "and". You got "(type -- file not *edit* or *200x200* and *.jpg) or *.png".

How to be?

To add parentheses:
find /var/www/test -type f ! -regex ".*\(edit\|200x200\).*" \( -name "*.jpg" -o -name "*.png" \)


If you do not use a regular expression that works:
$find /var/www/test -type f ! -name "*.jpg" -o -name "*.png"

...but not as it should.

Find more questions by tags bash