我尝试将以下字符串替换为多行,如下所示
setsid /usr/local/bin/Naming_Service ${OPTIONS} &
替换为
setsid /usr/local/bin/Naming_Service ${OPTIONS_13016} &
setsid /usr/local/bin/Naming_Service ${OPTIONS_13018} &
我试过这个命令
sed '0,/setsid \/usr\/var\/run\/Naming_Serivce ${OPTIONS}/s//setsid \/usr\/var\/run\/Naming_Serivce ${OPTIONS_13016}\n\setsid \/usr\/var\/run\/Naming_Serivce ${OPTIONS_13018}\n /' script > new_script
你能帮忙解决吗?
答案 0 :(得分:0)
sed 's/^\(.*\)\(${OPTIONS}\)\(.*\)$/\1${OPTIONS_13016}\3\n\1${OPTIONS_13018}\3/' < script > new_script
答案 1 :(得分:0)
对于您的要求,请使用以下语法
语法:
sed -e "s/setsid \/usr\/local\/bin\/Naming_Service \${OPTIONS}/setsid \/usr\/local\/bin\/Naming_Service \${OPTIONS_13016} \&\nsetsid \/usr\/local\/bin\/Naming_Service \${OPTIONS_13018}/g" script > new_script