Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #4121
| From | Markus Elfring <Markus.Elfring@web.de> |
|---|---|
| Newsgroups | comp.unix.programmer, comp.programming |
| Subject | Escaping of line breaks for text replacement |
| Date | 2014-03-02 14:00 +0100 |
| Message-ID | <bngoc5F196mU1@mid.individual.net> (permalink) |
Cross-posted to 2 groups.
Hello,
I get the following result if I try out such a command on my openSUSE system.
elfring@Sonne:~> $SHELL --version && sed --version && LINE='echo ---' && $LINE \
&& DRAFT='template1.txt' && cat $DRAFT && $LINE \
&& INPUT='replacement1.txt' && cat $INPUT && XY=$(< $INPUT) && $LINE \
&& LANG=C sed "s/# placeholder/$XY/" $DRAFT
GNU bash, Version 4.2.45(1)-release (x86_64-suse-linux-gnu)
...
sed (GNU sed) 4.2.2
...
---
+++++++++++++
# placeholder
*************
---
ABC
XYZ
---
sed: -e expression #1, char 19: unterminated `s' command
I guess that the shown error message is an indication that I should add a bit of
escaping to the content of the variable "XY" which I inserted previously. I have
tried to achieve this with shell pattern substitution.
elfring@Sonne:~> XY=$(< $INPUT) && XY=${XY//\\\n/./} && echo $XY
ABC XYZ
I wonder why I do not get this approach to work so far with some additional
backslashes here. How should newlines be escaped for this purpose?
Would you like to share any further ideas?
Regards,
Markus
Back to comp.programming | Previous | Next — Next in thread | Find similar | Unroll thread
Escaping of line breaks for text replacement Markus Elfring <Markus.Elfring@web.de> - 2014-03-02 14:00 +0100 Re: Escaping of line breaks for text replacement jt@toerring.de (Jens Thoms Toerring) - 2014-03-02 15:49 +0000 Re: Escaping of line breaks for text replacement dave.gma+news002@googlemail.com.invalid (Dave Sines) - 2014-03-02 16:52 +0000 Re: Escaping of line breaks for text replacement Kaz Kylheku <kaz@kylheku.com> - 2014-03-02 18:11 +0000 Re: Escaping of line breaks for text replacement Siri Cruz <chine.bleu@yahoo.com> - 2014-03-07 02:47 -0800
csiph-web