Quote:
Originally Posted by
4scriptmoni
sorry I got lost.
so what syntax should i use?
Notice the difference between the two command lines, both from your own post. The first one is correct, the second one isn't:
Quote:
Originally Posted by
4scriptmoni
sed '/alias 24x7-comunicacions/a\
blabla' servicegroup-24x7-comm.cfg>new.txt
sed '/alias 24x7-comunicacions/a\$LINEX' $FILECFG
The "\" character in the second one escapes the character "$", while in the first one it escapes (correctly) the newline character, which causes line to be continued in the next line. This character is not printable, so it is difficult to understand the concept at first. Correct is:
sed '/alias 24x7-comunicacions/a\
'"$LINEX" $FILECFG
Its like this: Think of
X
X
basically as the character sequeence
X<newline-char>X
and this newline-character (usually written as "\n", like the C expression which causes a newline character to be printed) has to be escaped so that sed doesn't think the command line ends there but takes this newline as part of the string to add.
I hope this clarifies things.
bakunin