S. Feunmajer
S. Feunmajer

Reputation: 325

find files matching several patterns in bash

I am trying to find all the files in a folder that ends with any of this expressions:

"00.png" or "25.png" or "50.png" or "75.png"

I am using the command

find . -type f -name '(*00.png|*25.png|*50.png|*75.png)'

with no success, what is the correct way to do it?

Upvotes: 3

Views: 746

Answers (2)

anubhava
anubhava

Reputation: 786091

Without using any regex you can use:

find . -name '*[05]0.png' -o -name '*[27]5.png'

If you are really keen to use regex then use this gnu find command:

find . -regextype egrep -regex '.*/([05]0|[27]5)\.png$'

Upvotes: 3

Jaay
Jaay

Reputation: 2153

You can use regex option of find command :

find . -type f -regextype posix-extended -regex '(.*00\.png|.*25\.png|.*50\.png|.*75\.png)'

Upvotes: 2

Related Questions