[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#20864: How to preserve newlines in sed text replacement command?
From: |
SF Markus Elfring |
Subject: |
bug#20864: How to preserve newlines in sed text replacement command? |
Date: |
Sun, 21 Jun 2015 15:15:24 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 |
Hello,
Are you interested to clarify escaping of new-line characters
a bit more?
http://sed.sourceforge.net/sedfaq4.html#s4.1
I would appreciate your advices for the following results
which I observe for the software version 4.2.2-7.1
on my openSUSE system.
address@hidden:~> cat test_template2.txt
*************
# placeholder
=============
address@hidden:~> XY=$(<two_lines.txt) && echo ">$XY<"
> one
| two<
address@hidden:~> sed "s%# placeholder%${XY//$'\n'/$'\\\\n'}%g"
test_template2.txt
*************
one\n| two
=============
address@hidden:~> LANG=C sed "s%# placeholder%${XY//$'\n'/$'\\\\\n'}%g"
test_template2.txt
sed: -e expression #1, char 23: unterminated `s' command
address@hidden:~> sed "s%# placeholder%${XY//$'\n'/$'\\\\\\n'}%g"
test_template2.txt
*************
one\
| two
=============
Which number of backslashes should be appropriate
for the desired pattern substitution in a shell variable?
Regards,
Markus
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#20864: How to preserve newlines in sed text replacement command?,
SF Markus Elfring <=