Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.fsmpi.rwth-aachen.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Markus Elfring Newsgroups: comp.unix.programmer,comp.programming Subject: Escaping of line breaks for text replacement Date: Sun, 02 Mar 2014 14:00:52 +0100 Lines: 38 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Trace: individual.net n5TzeptclREduH9RMVATeQ8Gdyix0NME+vcClfmtnNz+mEjZSV Cancel-Lock: sha1:kovFuoBf8OPl51u0xuioBAweuCo= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 Xref: csiph.com comp.unix.programmer:5148 comp.programming:4121 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