find regular expression question
Zak Johnson
zakj at nox.cx
Fri Sep 15 09:21:19 PDT 2006
Volodymyr Kostyrko wrote:
> Just stumbled upon some inconsistences in find(1) regular expressions
> parsing:
>
> [code]
> > :>a
> > find . -regex '^\./a\?$'
> > find . | grep '^\./a\?$'
> ./a
> [/code]
Find uses basic (obsolete) regular expressions by default; '?' is an
ordinary character. You can use either of the following instead:
find . -regex '^\./a\{0,1\}$'
find -E . -regex '^\./a?$'
find's '-E' option makes -regex use the extended regular expression
syntax, documented in re_format(7). GNU grep uses its own---slightly
different---re syntax, described in grep(1).
-Zak
More information about the freebsd-standards
mailing list