0

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Ċ‚

4

-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 /.

1

This used to be very simple, with:

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.