[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to match regex in bash? (any character)

From: Greg Wooledge
Subject: Re: How to match regex in bash? (any character)
Date: Tue, 27 Sep 2011 08:15:09 -0400
User-agent: Mutt/

On Mon, Sep 26, 2011 at 07:06:30PM -0800, Roger wrote:
> Some good reading I found is under the Bash Manual Page section "Parameter
> Expansion".
> From here, to learn more about regex/regexpr as the Bash Manual is quite brief
> on regex, use the following manual pages:
> perlretut - Gives a good from the start explanation of regular expressions,
> including perl

Perl's regular expressions are not the same as Bash's.  Bash uses standard
POSIX Extended Regular Expressions (ERE).  You can find formal documentation

Or see "man egrep", as egrep (or grep -E) also uses EREs.  Or see any
web page that discusses EREs.

Avoid reading documentation from a different language (in this case Perl),
because the features tend to change.  Perl uses a feature set and syntax
that have been retroactively dubbed Perl Compatible Regular Expressions
(PCRE).  They're superficially similar to EREs, but have a much broader
range of features (extensions) that are not compatible and will not work
in Bash.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]