Insert a line at specific line number with sed or awk

sed -i '8i This is Line 8' FILE

inserts at line 8

This is Line 8

into file FILE

-i does the modification directly to file FILE, no output to stdout, as mentioned in the comments by glenn jackman.

Leave a Comment