Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

(jeffa) Re: How do I remove blank lines from text files?

by jeffa (Bishop)
on Jul 11, 2000 at 01:42 UTC ( [id://21877]=note: print w/replies, xml ) Need Help??


in reply to How do I remove blank lines from text files?

I realize that I might be chastised for this, but
I feel the need to mention that this is a trivial
task for vi.

Type : and then issue this command

%g/^$/d
The percent sign tells vi 'do this for all lines in the
file.' The g operator means 'globally', and the
d operator means 'perform deletion on the lines
that match'.

Replies are listed 'Best First'.
RE: Re: How do I remove blank lines from text files?
by httptech (Chaplain) on Jul 11, 2000 at 06:48 UTC
    Of course, if you're going to bother to start up vi, you might as well just do perl -pi -e 's/^\n$//' file.txt But I think this exceeds the scope of the original poster's question, since his program is already parsing the file.
RE: Re: How do I remove blank lines from text files?
by le (Friar) on Jul 11, 2000 at 01:46 UTC
    You got a ++ from me -- vi rules! :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://21877]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-26 04:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found