Linux Bash: Insert Text To The Third 3rd Line From The Bottom Of A File


Very simple and quick... This just shows you the code you can use in a linux bash script to add something to a file but on the 3rd line from the bottom.

$ sed -zEi "s/(\n[^\n]*){3}$/\nNew-line&/" path/to/file/name.txt

Thats it, Good luck.