${[a-zA-Z0-9._:]*}
我已经使用上述模式来搜索类似于 ${SomeText} 的单词。如何在我的 bash 脚本中将 'SomeText' 替换为其他字符串,即 ${SomeText} --> SomeString?
示例:file.txt
text text text ${SomeText1} text text ${SomeText2} text text text text text text
text text text text ${SomeText3} text text text text text text ${SomeText4} text
...
我的脚本文件:
SomeText1="foo"
SomeText2="bar"
..
我想将 ${SomeText1} 替换为 $SomeText1,它将被 foo 替换。同样 ${SomeText2} > $SomeText2 > bar
text text text foo text text bar text text text text text text
text text text text baz text text text text text text qux text
...