Insert a line of text to the top of a file

May 29, 2010 โ€” If you have a massive text file you want to add a line to without opening the file, here's a quick solution:

sed -e '1i\text_to_insert' -i file.txt

View source