LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Re: sed question

[ILUG] Re: sed question

Brendan Kehoe brendan at zen.org
Thu Aug 14 15:15:59 IST 2008


> "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




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


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!
RSS Version
Powered by Dell