bug-sed
[Top][All Lists]
Advanced

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

bug#20864: How to preserve newlines in sed text replacement command?


From: Assaf Gordon
Subject: bug#20864: How to preserve newlines in sed text replacement command?
Date: Wed, 25 Jan 2017 02:09:12 +0000
User-agent: Mutt/1.5.23 (2014-03-12)

tag 20864 notabug
stop

Hello,

Sorry for the delayed response.

Are you interested to clarify escaping of new-line characters
a bit more?
http://sed.sourceforge.net/sedfaq4.html#s4.1

This sed FAQ page is not maintained by us (GNU sed developers),
and we can not change it.

Which number of backslashes should be appropriate
for the desired pattern substitution in a shell variable?

I think there is some delicate interplay between the shell
and sed in the examples you provided (for one, not all shells
support the $'\n' syntax).

It might be better to separate the steps and see which cause problems.

As for sed, A single backslash is what's needed to indicate
a newline character:

   $ echo xyz | sed 's/y/\n/' | od -c
   0000000   x  \n   z  \n

I'm marking this as 'done', but discussion can continue
by replying to this thread.

regards,
- assaf





reply via email to

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