Appending text, written in variable, below current line using sed

Tags:

Answer: 1

8 hours ago

I can append text below current line, using the sed editor:

$ foo=bar
$ echo "some text"|sed "a\bar"
some text
bar

But when I try to append text from variable below current line, using sed, I am not able to do it:

$ foo=bar
$ echo "some text"|sed "a\$foo"
some text
$foo
Added by: Mia West PhD

Answer: 2

17 hours ago

Escape the dollar sign using a backslash (\):

$ echo "some text"|sed "a\\$foo"
some text
bar

Works fine here.

Popular Search

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9