Discussion:
Strange Behavior s/ vs c\
n22e113 n22e113@yahoo.ca [sed-users]
2015-12-15 02:28:20 UTC
Permalink
Hi,Seders,
Can someone have a look (Debian 8/GUN sed 4.2.2)?
$ echo 'mail_location=mbox:~/mail:INBOX=/var/mail/%u' |\
sed -e 's/^mail_location\(.*\)$/#mail_location\1/'
#mail_location=mbox:~/mail:INBOX=/var/mail/%u

$ echo 'mail_location=mbox:~/mail:INBOX=/var/mail/%u' |\
sed -e '/^mail_location\(.*\)$/ c\#mail_location\1/'
#mail_location1/

Results are not the same with s/ & c\!
Q. What am I do wrong?
sharma__r@hotmail.com [sed-users]
2015-12-15 03:21:09 UTC
Permalink
The s/// and c\ commands do not behave similarly.
With the c\ command you cannot use parts of the pattern space, like you tried. It requires a hardcoded text as a replacement for the pattern space.
And with the added quirk, that it doesn't execute anything after the c\
command :-(

---In sed-***@yahoogroups.com, <***@...> wrote :

Hi,Seders,
Can someone have a look (Debian 8/GUN sed 4.2.2)?
$ echo 'mail_location=mbox:~/mail:INBOX=/var/mail/%u' |\
sed -e 's/^mail_location\(.*\)$/#mail_location\1/'
#mail_location=mbox:~/mail:INBOX=/var/mail/%u

$ echo 'mail_location=mbox:~/mail:INBOX=/var/mail/%u' |\
sed -e '/^mail_location\(.*\)$/ c\#mail_location\1/'
#mail_location1/

Results are not the same with s/ & c\!
Q. What am I do wrong?



[Non-text portions of this message have been removed]

Loading...