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

From Vick Khera
Subject Re: Record Separator with psql -c when output to a variable not a file!
Date
Msg-id AANLkTikj0sDPEtzV_jOY9wKxvB=RRc7ok3+S+Jx4S6r5@mail.gmail.com
Whole thread Raw
In response to Record Separator with psql -c when output to a variable not a file!  (andrew harvey <a.andrewharvey@gmail.com>)
List pgsql-general
On Mon, Oct 4, 2010 at 3:51 PM, andrew harvey <a.andrewharvey@gmail.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.

pgsql-general by date:

Previous
From: Miklosi Attila
Date:
Subject: error messages
Next
From: Vick Khera
Date:
Subject: Re: [Off Topic] Software load balancing question