using sed to replace 1 line with a multi-line variable in ksh
Posted
by
Manda
on Super User
See other posts from Super User
or by Manda
Published on 2014-06-10T01:42:24Z
Indexed on
2014/06/10
3:29 UTC
Read the original article
Hit count: 452
I have the following text in a file:
XXXX
NNNN
YYYY
NNNN
ZZZZ
NNNN
I want to replace the NNNN to make it look like this:
XXXX
NNNN
DUTY FORECASTER:
YYYY
NNNN
DUTY FORECASTER:
ZZZZ
NNNN
DUTY FORECASTER:
How do I use sed to replace a variable with more than one line? Is there a better way of doing this without using sed?
I have tried the following to no avail:
sed 's/NNNN/"$value1"/g' testfile
sed 's/NNNN/'"$value1"'/g' testfile
sed 's/NNNN/${value1}/g' testfile
sed 's/NNNN/'"${value1}"'/g' testfile
I have also tried all of the above using double quotes. Any help is greatly appreciated. Thanks so much!
© Super User or respective owner