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/a\We 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.