Home > Blockchain >  find files matching several patterns in bash
find files matching several patterns in bash

Time:03-07

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?

CodePudding user response:

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$'

CodePudding user response:

You can use regex option of find command :

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