in reply to Elegant Way of Inserting Text at the Start of the File
Either of these:
perl -i -wpe 'print "new text\n" if $. == 1;' file
See perlrun for the meanings of the command-line flags.perl -MTie::File -we 'tie @L, "Tie::File", "file" or die; unshift @L, +"new text";'
|
|---|