Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: One-liner removes whitespace-only lines from text file

by FoxtrotUniform (Prior)
on Dec 19, 2001 at 02:21 UTC ( #132956=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    perl -i.bak -ne 'print if /\S/' file.txt 
    
  2. or download this
    perl -i.bak -ne 's/^\s+$//;print' file.txt 
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://132956]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2016-12-02 22:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (51 votes). Check out past polls.