sed: missing LF

Claus Klein claus.klein at marconi.com
Fri Mar 2 08:38:01 UTC 2007


On Wednesday, 28. February 2007 17:30, you wrote:
> sed "/^ADDRESS/c\ADDRESS=1.2.3.4"

Hallo,

why use 'c\A...'

from man page:

       c \

       text   Replace the selected lines with text, which has each embedded newline preceded by a backslash.
---------
It is not clear to me if the \n should be embedded or not?

Would it not better to use:

sed -e 's/regexp/replacement/' filename

->
sed -i -e 's/^ADDRESS.*$/ADDRESS=1.2.3.4/' filename

That works fine:

[root at bkvme2:~]# sed  -e 's/^ADDRESS.*$/ADDRESS=1.2.3.4/' test.txt
ADDRESS=1.2.3.4
NETMASK=
GATEWAY=
[root at bkvme2:~]# cat test.txt
ADDRESS=
NETMASK=
GATEWAY=
[root at bkvme2:~]#


Claus Klein



More information about the busybox mailing list