I have a string which I want to replace. It is of the format:
VAL1 = "D_AC" ,
VAL2 = "DRC" ,
VALX2 = 3.33330000e+04, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
Note that the string has both double quotes and newline characters.
I want to replace it with another string:
VAL1 = "D_AC" ,
VAL2 = "DRC" ,
VALX2 = 2.22110000e+04, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
Ive tried:
export OLD_STRING1=" VAL1 = \"D_AC\" ,"
export OLD_STRING2=" VAL2 = \"DRC\" ,"
export OLD_STRING3=" VALX2 = 3.33330000e+04, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, "
export NEW_STRING1=" VAL1 = \"D_AC\" ,"
export NEW_STRING2=" VAL2 = \"DRC\" ,"
export NEW_STRING3=" VALX2 = 2.22110000e+04, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, "
Then called grep
and sed
as so:
find . -type f -name '*filename*' -exec sed -i '' s/$OLD_STRING1$OLD_STRING2$OLD_STRING3/$NEW_STRING1$NEW_STRING2$NEW_STRING3/ {} +
sed
generates an error:
sed: 1: "s/BX2 = "D_AC ...": unterminated substitute pattern
How could I resolve this?