用变量的形式,把hello替换为world
a=world
echo hello|sed "s/^.*/$a/g"
若变量a中有”/”,则可以这样
a=/root/world.txt
echo hello|sed "s#^.*#$a#g" #Right
echo hello|sed "s/^.*/$a/g" #Error
时间: 2024-10-24 03:45:53
a=world
echo hello|sed "s/^.*/$a/g"
a=/root/world.txt
echo hello|sed "s#^.*#$a#g" #Right
echo hello|sed "s/^.*/$a/g" #Error