[root@server ~]# a="test1" [root@server ~]# b="2test" [root@server ~]# echo $a | sed "s 1 $b " test2test [root@server ~]#
即--> 格式为sed "s $变量1 $变量2 ",注意一定是双引号,这里以空格为分隔符,正常可以使用sed "s/$变量1/$变量2/ "
[root@server ~]# a="test1" [root@server ~]# b="2test" [root@server ~]# echo $a | sed "s 1 $b " test2test [root@server ~]#