[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GUN Sed Bug
From: |
Eric Blake |
Subject: |
Re: GUN Sed Bug |
Date: |
Fri, 26 Oct 2012 15:10:35 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121016 Thunderbird/16.0.1 |
On 10/26/2012 03:06 PM, Eric Blake wrote:
> On 10/26/2012 06:42 AM, 王森 wrote:
>
>> address@hidden learn_sed]# /bin/sed "s/\'/ End/" tmp.txt
>> hello world End
>> I'am in china End
>> address@hidden learn_sed]#
>> ### My Question
>> I want to know the reason. \' be equal to Line End ?
>
> Thanks for the report. However, this is not a bug, but a GNU extension,
> as documented here:
> https://www.gnu.org/software/sed/manual/html_node/Escapes.html#Escapes
>
> In your particular case, end of line and end of input happen to match.
> But if your sed script had also used commands like 'N', then you could
> see a difference where multi-line mode makes \' match fewer places than $.
By the way, POSIX says \' in sed is not portable, because
implementations differ on whether it matches a literal ' or is treated
like the GNU extension. If you were trying to match the literal ', then
lose the backslash in your sed script.
--
Eric Blake address@hidden +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature