Removing blank lines

R

Robert Klemme

Simon said:
Yep!

ruby -i.bak -ple 'next if $_==""' test

Inplace editing with backup file.

Without inplace editing

ruby -pne 'next if /^\s*$/' test
ruby -ne 'puts $_ unless /^\s*$/' test

Kind regards

robert
 
T

tony summerfelt

Robert Klemme wrote on 10/13/2005 4:01 AM:
this thread (and the removing duplicate lines thread) are a good
example of ruby's tim toadie.

i would have probably come up with the a variation on the gsub examples.


--=20
http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org
 
J

Jacob Fugal

Robert Klemme wrote on 10/13/2005 4:01 AM:

this thread (and the removing duplicate lines thread) are a good
example of ruby's tim toadie.

i would have probably come up with the a variation on the gsub examples.

I would call it more of an example of TIMTOWTDI for *n*x in general.
You can write a short script in any number of languages, or use any
number of already built tools (awk, grep) to do it. Myself, I'd just
use my trusty old grep (I'll concede it's not readily available on a
default windows install).

Know thy tools -- only reinvent the wheel if it *needs* reinventing.

Jacob Fugal
 
T

tony summerfelt

Jacob Fugal wrote on 10/14/2005 11:23 AM:
Know thy tools -- only reinvent the wheel if it *needs* reinventing.

for the most part i DO know my tools. that's why i have to reinvent
some of them. although mostly on the windows side
 
R

Robert Klemme

tony said:
Jacob Fugal wrote on 10/14/2005 11:23 AM:


for the most part i DO know my tools. that's why i have to reinvent
some of them. although mostly on the windows side

LOL

Adding to that: at times it's just fun to reinvent some of the weels...
:)

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top