Search code examples
bashfindzsh

Find for YML and YAML files on bash find


I am trying to find all .yaml and .yml

I tried

find . -name '*.{yml,yaml}' -exec echo "{}" \;

But no results

Neither in the following way

find . -name '*.yml' -name '*.yaml' -exec echo "{}" \;

Returns nothing.

Is it possible to use the find command to search for both extensions?


Solution

  • With GNU find find none or one a:

    find . -regextype egrep -regex '.*ya?ml$'
    

    or

    find . -regextype egrep -regex '.*ya{0,1}ml$'
    

    See: man find