in reply to Elegant Way of Inserting Text at the Start of the File
A few slightly different methods:
perl -0i -wpe's/^/new line\n/' file perl -0i -wpe'substr $_,0,0,"new line\n"' file perl -i -wlpe'print "new line" if 1..1' file
All of the above assume (much like some of the ideas suggested by other people here) that the file already has some content; they will not work if it's completely empty.
|
|---|