問題1插入:查找模式並更換整條生產線和尋找模式和後
模式:
test_$(whoami)
變量:
var1=$(pwd)
我想找到的模式,用var1
代替整行
sed -i "s/.*test_$(whoami).*/$var1/" test.txt
它給我的sed:-e表達式#1,焦炭28:未知的選項爲'S'
問題2.
模式:
#####Insert here#####
內容是插入:包括$ VAR1 /file_$(whoami).txt
我想找到與模式(完全匹配)就行了,之後插入內容一行
sed -i "s/#####Insert here#####/include $var1/file_$(whoami).txt" test.txt
也不管用
有人可以幫忙嗎?