Создайте файл ascii test.txt со следующим содержимым:
Try to replace this ${myTestVariable1}
bla bla
....
Теперь создайте файл «sub.sed», содержащий имена переменных, например
's,${myTestVariable1},'"${myTestVariable1}"',g;
s,${myTestVariable2},'"${myTestVariable2}"',g;
s,${myTestVariable3},'"${myTestVariable3}"',g;
s,${myTestVariable4},'"${myTestVariable4}"',g'
Открыть терминал переместится в папку, содержащую test.txt и sub.sed. Определите значение заменяемой переменной
myTestVariable1=SomeNewText
Теперь вызовите sed, чтобы заменить эту переменную
sed "$(eval echo $(cat sub.sed))" test.txt > test2.txt
Выход будет
$cat test2.txt
Try to replace this SomeNewText
bla bla
....