Appending lines

Append line after line 2

$ sed '2a Text after line 2' file.txt

Append line at the end of the file

$ sed '$a THE END!' file.txt

Append line after every 3rd line starting from line 3

$ sed '3~3a Some text' file.txt
Comments