Removing blank lines

Hello,
How does one delete blank lines from a text file? (I did try a number
of things, but, I can't get any to work.)
Thanks,
basi

Hello Basi,

Hello,
How does one delete blank lines from a text file? (I did try a number
of things, but, I can't get any to work.)

---------------------------------- 8< ----------------------------------
zoso@velutha:~/tmp$ cat >test
one

two

three
four

five
zoso@velutha:~/tmp$ ruby -e 'puts File.readlines("test").find_all {|line| line !~ /^$/}'
one
two
three
four
five
---------------------------------- >8 ----------------------------------

Or you mean writing back the result to the file? In that case, I guess you'll
have to write it to another, temporal file, and then move it to the original
path.

    Regards,

···

On Thu, Oct 13, 2005 at 03:26:52AM +0900, basi wrote:

--
Esteban Manchado Velázquez <zoso@foton.es> - http://www.foton.es
EuropeSwPatentFree - http://EuropeSwPatentFree.hispalinux.es

basi wrote:

Hello,
How does one delete blank lines from a text file? (I did try a number
of things, but, I can't get any to work.)
Thanks,
basi

awk 'NF' infile >outfile

Hi,

At Thu, 13 Oct 2005 03:26:52 +0900,
basi wrote in [ruby-talk:160238]:

How does one delete blank lines from a text file? (I did try a number
of things, but, I can't get any to work.)

  grep -v ^$ infile > outfile

To remove also lines contain whitespaces only:

  grep -v '^[ ]*$' infile > outfile

···

--
Nobu Nakada

Can anyone share their opinions on the best resource for information on rails/postgres config and setup? I'd prefer to not use MySQL due to licensing issues.

Also, I'd appreciate if anyone would share their opinions on the best GUI for postgres on Linux and/or Macs.

Thanks!
-k

similar:

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

Regards,
  Stefan

···

On Wednesday 12 October 2005 20:32, Esteban Manchado Velázquez wrote:

Hello Basi,

On Thu, Oct 13, 2005 at 03:26:52AM +0900, basi wrote:
> Hello,
> How does one delete blank lines from a text file? (I did try a
> number of things, but, I can't get any to work.)

zoso@velutha:~/tmp$ ruby -e 'puts File.readlines("test").find_all
{|line| line !~ /^$/}'

Hello Basi,

> Hello,
> How does one delete blank lines from a text file? (I did try a
> number of things, but, I can't get any to work.)

[...]

Or you mean writing back the result to the file? In that case, I
guess you'll have to write it to another, temporal file, and then
move it to the original path.

Without tempfile:

    ruby -e 'text = File.read "text"; open "text", "w" do |f| f <<
text.gsub(/\n{2,}/, "\n") end'

Regards,
  Stefan

···

On Wednesday 12 October 2005 20:32, Esteban Manchado Velázquez wrote:

On Thu, Oct 13, 2005 at 03:26:52AM +0900, basi wrote:

Thanks much! Yes, I'd have to use a temporary file, but there are
examples of this in the cookbook and I should be able to follow them
Cheers!
basi

William James wrote:

basi wrote:
> Hello,
> How does one delete blank lines from a text file? (I did try a number
> of things, but, I can't get any to work.)
> Thanks,
> basi

awk 'NF' infile >outfile

Here's another. Remove blank lines (lines that are empty or contain
only whitespace) from beginning of file. After first non-blank line,
keep all remaining lines.

awk 'NF,0' infile >outfile

Wow, so many people who'd like to help. Overwhelmed I am again. Thank
you!
basi

Can anyone share their opinions on the best resource for information
on rails/postgres config and setup? I'd prefer to not use MySQL due
to licensing issues.

I've been running PostgreSQL 8 and Rails on Linux for a month or so with
the pure Ruby driver; all seems well. Any particular area causing
problems?

Also, I'd appreciate if anyone would share their opinions on the best
GUI for postgres on Linux and/or Macs.

Can't help there, I've just been using psql...

Yours,

Tom

···

On Thu, 2005-10-13 at 03:38 +0900, Kevin Bedell wrote:

To Stefan and Kevin,
Thank you much for taking the time to reply. Much appreciated.
basi

Also, I'd appreciate if anyone would share their opinions on the best
GUI for postgres on Linux and/or Macs.

Please, please, please tell me someone knows of a better frontend for
postgres for OS X than BiggerSQL and pgAdmin3.

I've been inflicting those two upon myself for far too long now.

···

--
Bob Aman

Yeah, same here, I'd go for Sqlite3 or Postgres. I just got Sqlite3
gem-installed and am just about ready to try it. Then I saw Instrant
Rails, which uses MySql and I'm now downloading it. Decisions,
decisions, ...

Stefan Lang <langstefan@gmx.at> writes:

Hello Basi,

> Hello,
> How does one delete blank lines from a text file? (I did try a
> number of things, but, I can't get any to work.)

zoso@velutha:~/tmp$ ruby -e 'puts File.readlines("test").find_all
{|line| line !~ /^$/}'

similar:

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

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

Know thy tools :slight_smile:

···

On Wednesday 12 October 2005 20:32, Esteban Manchado Velázquez wrote:

On Thu, Oct 13, 2005 at 03:26:52AM +0900, basi wrote:

  Stefan

--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org

I've been pretty happy with pgadmin3, though pgaccess was easier to get
up and running from source (pgadmin3 requires a unicode-enabled wxGTK -
if you're using gentoo, you need to update your binutils before
compiling it). Nothing equivalent to dbdesigner4, sadly.

martin

···

Kevin Bedell <kevin@kbedell.com> wrote:

Also, I'd appreciate if anyone would share their opinions on the best
GUI for postgres on Linux and/or Macs.

Can anyone share their opinions on the best resource for information
on rails/postgres config and setup? I'd prefer to not use MySQL due
to licensing issues.

There really isn't anything different about using postgresql other than the
parameters in database.yml. There is some stuff in the how to sections on
the websites about using views, etc..

Also, I'd appreciate if anyone would share their opinions on the best

GUI for postgres on Linux and/or Macs.

pgadmin is good, clean, simple, lightweight.. EMS postgresql manager lite is
probably the best free gui, although I prefer pgadmin because it's lighter
and I don't need all the features of EMS postgresql manager.

Chris

Thanks!

···

On 10/12/05, Kevin Bedell <kevin@kbedell.com> wrote:

-k

Opps, that was meant for Stefan...

Bob Aman wrote:

Also, I'd appreciate if anyone would share their opinions on the best
GUI for postgres on Linux and/or Macs.

Please, please, please tell me someone knows of a better frontend for
postgres for OS X than BiggerSQL and pgAdmin3.

I've been inflicting those two upon myself for far too long now.
--
Bob Aman

You might want to look at Aqua Data Studio: http://www.aquafold.com/

···

--
Daryl

phppgadmin is what I use here, and I'm very happy with it.

Caleb

···

On Wednesday 12 October 2005 02:01 pm, Bob Aman wrote:

> Also, I'd appreciate if anyone would share their opinions on the best
> GUI for postgres on Linux and/or Macs.

Please, please, please tell me someone knows of a better frontend for
postgres for OS X than BiggerSQL and pgAdmin3.