Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
GUN Sed Bug
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
王森  
View profile  
 More options Oct 26 2012, 8:42 am
Newsgroups: gnu.utils.bug
From: 王森 <wangs2010...@163.com>
Date: Fri, 26 Oct 2012 20:42:41 +0800 (CST)
Local: Fri, Oct 26 2012 8:42 am
Subject: GUN Sed Bug
Hi
### tmp.txt ###
[root@localhost learn_sed]# cat tmp.txt
hello world
I'am in china
[root@localhost learn_sed]#
[root@localhost learn_sed]# sed --version
GNU sed version 4.2.1
[root@localhost learn_sed]# which sed
/bin/sed
[root@localhost learn_sed]# /bin/sed 's/$/ End/' tmp.txt
hello world End
I'am in china End
[root@localhost learn_sed]#
[root@localhost learn_sed]#
[root@localhost learn_sed]# /bin/sed "s/\'/ End/" tmp.txt
hello world End
I'am in china End
[root@localhost learn_sed]#
### My Question
I want to know the reason.  \' be equal to Line End ?
If possible , tell me why ?   thanks

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Blake  
View profile  
 More options Oct 26 2012, 5:06 pm
Newsgroups: gnu.utils.bug
From: Eric Blake <ebl...@redhat.com>
Date: Fri, 26 Oct 2012 15:06:31 -0600
Local: Fri, Oct 26 2012 5:06 pm
Subject: Re: GUN Sed Bug

On 10/26/2012 06:42 AM, 王森 wrote:

> [root@localhost learn_sed]# /bin/sed "s/\'/ End/" tmp.txt
> hello world End
> I'am in china End
> [root@localhost 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 $.

--
Eric Blake   ebl...@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

  signature.asc
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Blake  
View profile  
 More options Oct 26 2012, 5:10 pm
Newsgroups: gnu.utils.bug
From: Eric Blake <ebl...@redhat.com>
Date: Fri, 26 Oct 2012 15:10:35 -0600
Local: Fri, Oct 26 2012 5:10 pm
Subject: Re: GUN Sed Bug

On 10/26/2012 03:06 PM, Eric Blake wrote:

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   ebl...@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

  signature.asc
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »