Given a file file.txt with the following content:
line 1
line 2
line 3
You can add a new line using below command
sed '/line 2/{x;p;x;}' file.txt
The above command will output
line 1
line 2
line 3
Explanation:
x command is eXchange. sed has a buffer that you can use to store some ...