Re: multiple sql results to shell

From: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>
To: Randy Strauss <rstr(at)stanford(dot)edu>, "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: multiple sql results to shell
Date: 2017-10-24 09:58:18
Message-ID: CAEzk6ffJ+Br0tRcL2e+VhPUfdicR2wObh8S=tdwJ1+o7+Sof=g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

On 23 October 2017 at 23:14, Randy Strauss <rstr(at)stanford(dot)edu> wrote:
> To get input from a file w/o a sub-shell,
> you can put the input at the end of the loop:

That's a good point: and it also jogged my memory that in bash you can
do process substitution, so

while read a; do $a; done < <(psql -tqAX -c 'SELECT ...')

will keep the read loop in the main process, not the child (unlike the
"| while read" syntax)

Geoff

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Bear Giles 2017-10-24 16:39:16 Re: Processing very large TEXT columns (300MB+) using C/libpq
Previous Message Randy Strauss 2017-10-23 22:14:28 Re: multiple sql results to shell

Browse pgsql-general by date

  From Date Subject
Next Message basti 2017-10-24 13:12:02 Allow only certain query on replication slave
Previous Message Rhhh Lin 2017-10-24 00:08:55 Re: Backup strategy using 'wal_keep_segments'