[Top][All Lists]

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

Re: sed backslash back-quote is carat (^)?

From: Eric Blake
Subject: Re: sed backslash back-quote is carat (^)?
Date: Fri, 21 Jul 2006 01:52:10 +0000

> I used this gnu sed command, overly escaped, and got surprised (sed is
> Solaris 8 sed, gsed is gnu sed-3.02.80).  In gnu sed '\`' seems to be like
> '^', an undocumented feature:

Actually, it is a well-documented feature; you just weren't reading the
right documentation :)  In general, it is a bad idea to use more \ than
what BRE or ERE regular expression syntax requires, because it
is up to the implementation to assign additional meanings to those
additional escape sequences.  The GNU regex engine has defined \`
to mean the beginning of the whole input when requested in a
particular regex flavor, and sed chose to request it (\` is stronger
even than ^ when matching over multiple lines, since ^ only matches
beginning of individual lines).

If you have a sufficiently recent findutils installation (I'm using 4.3.0),
try 'info find.info Reference "Regular Expressions"' for a good overview
of all the various GNU regular expression flavors, including sed.  This
documents \`, and all other GNU extensions in each flavor.

Eric Blake

reply via email to

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