using sed to replace 1 line with a multi-line variable in ksh
- by Manda
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!