[ILUG] Re: sed question
Marcus Furlong
furlongm at hotmail.com
Thu Aug 14 15:51:53 IST 2008
Brendan Kehoe <brendan <at> zen.org> writes:
> > Does anyone know a one-liner sed/awk/perl to add a blank line to
> > the start of a file? It seems to work fine if I add a blank line.
>
> maybe for awk try either
>
> awk '{if(NR==1) print ""; print;}'
> awk 'BEGIN{print ""} {print;}'
>
> or perl
>
> perl -e 'print "\n"; while (<>) { print $_; }'
> perl -e 'print "\n"; print while <>;'
Thanks for those, I worked out the following one which works as well:
perl -e 'print "\n" if $. == 1'
Marcus.
More information about the ILUG
mailing list