我想用sed -e替换文件中的多个短语。问题是我想用字符串替换某些短语是否仍然存在这样做?因为当我这样做时使用
sed -e 's/foo/$bar/' -e 's/some/$text/' file.whatever
然后它没有任何影响...
答案 0 :(得分:2)
当你说带有字符串时,我认为你的意思是带有变量。如果是这种情况,只需使用双引号而不是单引号括住sed
命令。前者允许变量扩展,后者不允许。
sed -e "s/foo/$bar/" -e "s/some/$text/" file.whatever