sed tutorial: sed add line after match
Sed add line after match, you can use sed function: a , to add a new line after the matched string.
syntax
➜ sed '/option/a newLine' file
examples
In the following sed example, we will introduce how to add a new line after specifying the matching content. E.g, Add a new line after the line containing the string “hello”: “sed add a new line”
➜ ~ sed '/hello/ased add a new line' test.log

In addition to adding new lines after matching content, sed can also add new lines after specifying the line number. E.g:
Add a new line after the first line: “sed add a new line”
➜ ~ sed '1ased add a new line' test.log

Add a new line after the last line: “sed add a new line”
➜ ~ sed '$ased add a new line' test.log

We can use sed Na (0<N<=number of file lines) to add a new line after any line.
In the above example, we can use the sed command to add a new line after any specified line or specified content.
We can add a new line after all the lines.
➜ ~ sed '/$/ased add a new line' test.log
