Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by jeffa (Bishop)
on Jul 11, 2000 at 01:42 UTC ( #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
Node Status?
node history
Node Type: note [id://21877]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2020-10-20 21:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (210 votes). Check out past polls.

    Notices?