【发布时间】:2013-10-23 14:56:39
【问题描述】:
问题一:
图案:
test_$(whoami)
变量:
var1=$(pwd)
我想找到模式并将整行替换为var1
sed -i "s/.*test_$(whoami).*/$var1/" test.txt
它给了我 sed: -e expression #1, char 28: unknown option to `s'
问题 2。
图案:
#####Insert here#####
要插入的内容:包括 $var1/file_$(whoami).txt
我想找到与模式匹配的行(完全匹配),并在后一行插入内容
sed -i "s/#####Insert here#####/include $var1/file_$(whoami).txt" test.txt
也不行
有人可以帮忙吗?
【问题讨论】:
标签: regex linux bash replace sed