Replace a string in shell script using a variable

后端 未结 10 1086
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 05:18

I am using the below code for replacing a string inside a shell script.

echo $LINE | sed -e \'s/12345678/\"$replace\"/g\'

but it\'s getting

10条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 05:48

    you can use the shell (bash/ksh).

    $ var="12345678abc"
    $ replace="test"
    $ echo ${var//12345678/$replace}
    testabc
    

提交回复
热议问题