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.