Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by davorg (Chancellor)
on Jul 10, 2000 at 21:43 UTC ( [id://21832]=note: print w/replies, xml ) Need Help??


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

Depends what exactly you mean by a 'blank line'. Assuming that you mean a line that contains only white space characters then you can do something like this:

while (<>) { print if /\S/; }

And you can do the same thing from the command line

perl -i.bak -n -e "print if /\S/" filename
--
<http://www.dave.org.uk>

European Perl Conference - Sept 22/24 2000, ICA, London
<http://www.yapc.org/Europe/>

Replies are listed 'Best First'.
Re^2: How do I remove blank lines from text files?
by 92sai (Novice) on Jun 18, 2015 at 09:09 UTC
    how to remove blank lines in an xml file after modifying it??

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-03-28 11:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found