Reputation: 9400
Let's say I have the following two files in my directory
- test.yaml
- test.yml
On Ubuntu, the following bash command lists both the files:
$ find . -regex '.*\.ya?ml'
./test.yaml
./test.yml
However, on OS X the same command does not list any file:
$ find . -regex '.*\.ya?ml'
My question, what is the regular expression pattern that can passed to -regex
param, so the command works on both platforms?
Upvotes: 1
Views: 70
Reputation: 785856
find
available on OSX requires -E
for supporting extended regular expressions. On OSX following will work:
find -E . -regex '.*\.ya?ml'
Following will also work on OSX without needing extended regex:
find . -regex '.*\.ya\{0,1\}ml'
EDIT: If you want a common find
for both systems then use:
find . -regex '.*\.ya*ml'
Upvotes: 3