sed追加文本-sed脚本追加文本

input为sed输入文件,内容如下:

1 [root@node1 gitlab-test-1]# cat inppu.txt 
2 aa bb cc dd

追加文本:

  1、匹配  aa 行之后追加文本 We append a new line.

1 [root@node1 gitlab-test-1]# sed  '/aa/aWe append a new line.' inppu.txt 
2 aa bb cc dd
3 We append a new line.  #说明已经匹配到了aa 后在 aa行下追加了  We append a new line. 内容

sed脚本追加文本

[root@node1 gitlab-test-1]# cat append.sed 
#!/bin/sed -f
/aa/a
We append a new line.
root@node1 gitlab-test-1]# ./append.sed inppu.txt 
aa bb cc dd
We append a new line.
原文地址:https://www.cnblogs.com/nb-blog/p/10368397.html