I want to add a line at top of file say f1 using awk
Is there a better way than :
awk 'BEGIN{print "word"};{print $0}' f1 > aux;cp aux f1;\rm aux
does awk has something like -i option in sed.
views:
405answers:
2
+1
A:
Why not use sed - it would make the solution more straightforward
$sed -i.bak '1i\
word
' <filename>
Beano
2009-05-26 11:46:37
How can I echo newlines using the above script
Neeraj
2009-05-26 13:56:24
Just add them in - replace "word" with "work<cr>word"
Beano
2009-05-26 15:12:15