Re: Record Separator with psql -c when output to a variable not a file!

From: Vick Khera <vivek(at)khera(dot)org>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Record Separator with psql -c when output to a variable not a file!
Date: 2010-10-05 11:46:55
Message-ID: AANLkTikj0sDPEtzV_jOY9wKxvB=RRc7ok3+S+Jx4S6r5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Oct 4, 2010 at 3:51 PM, andrew harvey <a(dot)andrewharvey(at)gmail(dot)com> wrote:
> command="`psql  -c "SELECT * FROM pg_stat_database`"
>
> when you retain the query result within the variable $command you need
> to count all the fields in the entire output in order to select the
> particular one that you want. (because the record separator newline
> doesn't apply to within the variable named above) Therefore all the
> sql output is bundled up into one string with very, very many fields.
>

To be clear, the backtick expression in the shell is what is eating
the newlines and converting them to spaces. That's part of the
definition of how the backticks work.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Vick Khera 2010-10-05 11:53:27 Re: [Off Topic] Software load balancing question
Previous Message Miklosi Attila 2010-10-05 11:19:36 error messages