1,sed中引入shell变量
eval sed 's/$a/$b/' filename
sed "s/$a/$b/" filename
sed 's/'$a'/'$b'/' filename
sed s/$a/$b/ filename
2,sed的参数是变量,变量中有特殊字符
当使用sed命令替换内容时,有时会用到变量,如
sed -i "s/^abc=[ -~]*/app=$2/g" fileName,$2="djdh/dfsadf/sdfa",这时要怎么办?
将命令行中/换成?即可
sed -i "s?^abc=[ -~]*?app=$2?g" fileName