> "first" is also on the first line of the input file. Apart from that it works
> fine, thanks. 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.
>
In a single step? Aside from
#!/bin/sh
echo > new-"$1"
cat "$1" >> new-"$1"
mv "$1" old-"$1"
mv new-"$1" "$1"
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 <>;'
? I'm sure there are great terse ways to do the same in each (and in
sed, which I've never obsessed on enough).
Hope this helps,
B
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!