Removing blank lines

Christian Neukirchen wrote:

Stefan Lang <langstefan@gmx.at> writes:

similar:

   ruby -e 'puts File.read("test").gsub(/\n{2,}/, "\n")'

      ruby -e 'print File.read("t").squeeze("\n")'

Know thy tools :slight_smile:

Yep!

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

Inplace editing with backup file.

cheers

Simon

Simon Kröger wrote:

Christian Neukirchen wrote:

Stefan Lang <langstefan@gmx.at> writes:

similar:

   ruby -e 'puts File.read("test").gsub(/\n{2,}/, "\n")'

      ruby -e 'print File.read("t").squeeze("\n")'

Know thy tools :slight_smile:

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

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.

···

Robert Klemme wrote on 10/13/2005 4:01 AM: > Simon Kröger wrote:

Christian Neukirchen wrote:

Stefan Lang <langstefan@gmx.at> writes:

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

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

···

On 10/14/05, tony summerfelt <snowzone5@hotmail.com> wrote:

Robert Klemme wrote on 10/13/2005 4:01 AM: > > Simon Kröger wrote:
>>Christian Neukirchen wrote:
>>>Stefan Lang <langstefan@gmx.at> writes:

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.

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

···

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

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

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

tony summerfelt wrote:

···

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

LOL

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

    robert