我尝试在我的脚本中执行sed命令,以便在遇到搜索模式时在另一行上面插入文本。我试过了' a'命令插入文本,但我无法使其工作。
sed '/Splitter/a \ "help" ' fileList.out
sed:1:" / Splitter / a \" help" ":在命令结尾处\后的额外字符
machine-1:Splitter machine-1$ sed '/Splitter /"help" /a \ ' fileList.out
sed:1:" / Splitter /" help" / a \":无效的命令代码"
machine-1:Splitter machine-1$ sed '/Splitter /"help" a \ ' fileList.out
sed:1:" / Splitter /" help" a \":无效的命令代码"
machine-1:Splitter machine-1$ sed '/Splitter/"help"/a \ ' fileList.out
sed:1:" / Splitter /" help" / a \":无效的命令代码"
machine-1:Splitter machine-1$ sed '/Splitter/help/a \ ' fileList.out
sed:1:" / Splitter / help / a \":h命令末尾的额外字符
machine-1:Splitter machine-1$ sed '/Splitter/a \ ' fileList.out
//文件列表
./分配器/视图
./分配器/应用
./分配器/的Util
./分离器/主
./分离器/检查/ SplitImage
./ SplitterTests / SplitterTests
./分配器/ SplitterITests
machine-1:Splitter machine-1$ sed '/Splitter/a \ ' fileList.out
答案 0 :(得分:1)
答案 1 :(得分:0)
要在匹配的行中插入文字 ,请使用i
命令:
sed '/Splitter/i \
"help"
' fileList.out