How to prepend to a Linux file

How to insert line to the beginning of file on Linux

$ sed '1 s/^/This is the line to prepend\n/' file-to-be-prepended

Modify in place:

$ sed  -i '1 s/^/This is the line to prepend\n/' file-to-be-prepended

Comments