I have problem with find and regular expression. I would like to find files in /etc, which name begin of a or b. I tried this commands:

find /etc -type f -regex '^a'
find /etc -regextype sed -regex "^a"
find /etc -regextype egrep -regex '^a'
find /etc -regextype posix-egrep -regex '^a'

But not working. I have 20 files in /etc which name begin of a, but my regexp not find this files. What i do wrong?

Regards Paweł


2 Answers 2


-regex matches the complete path, not the filename only.

The closest thing I came up with would be:

find /etc -type f  -regex '.+/[ab][^/]+'

This matches a /, followed by a or b, followed by everything which is not another /.


This used to be very simple, with:

find /etc -type f -name 'a*'

Not the answer you're looking for? Browse other questions tagged .