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

Re: bullseye fslint



On Fri, Apr 23, 2021 at 11:29:59AM -0400, The Wanderer wrote:
> On 2021-04-23 at 11:27, Greg Wooledge wrote:
> 
> > On Fri, Apr 23, 2021 at 07:50:45AM -0400, The Wanderer wrote:
> > 
> >> grep -i 'fs|filesystem'" finds rmlint, which looks like it might do
> >> the
> > 
> > FYI that needs to be egrep, or grep -E, in order for the | character 
> > to work as you intend.
> 
> Yeah - sorry, I retyped rather than copying, and didn't realize the
> difference it made until I'd already hit Send.
> 
> It always seems bizarre to me that that would be one of the characters
> that needs escaping to have a special function in standard regex, and
> consequently I always have trouble remembering it...

It's all historical.  There's no rhyme or reason to it, except that
various tools worked this way starting in the 1970s.  Then some merging
and standardization was done, with the result that there are two standard
regex flavors in POSIX -- Basic and Extended.

grep and sed use BRE (Basic Regular Expressions) by default, and in BRE
you don't have | ? + operators, and you use \{ \} for expressing counts.

grep -E and awk use ERE (Extended Regular Expressions), which gives you
the | ? + operators, and you use { } for counts and ( ) for grouping.

It gets worse the deeper you dive into it, with PCRE and GNU extensions
flying around, a proposal to add -E to sed, etc.


Reply to: