Order of execution in shell echo to psql

From: John Gage <jsmgage(at)numericable(dot)fr>
To: PostgreSQL - General <pgsql-general(at)postgresql(dot)org>
Subject: Order of execution in shell echo to psql
Date: 2010-05-02 12:13:52
Message-ID: 857721FD-7443-4B3E-A06E-FA3D8FDF0573@numericable.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I issue the following command to the shell:

echo '\o file.txt \\ select * from table_name limit 10 \o ' | psql --
host 'localhost' --port 5432 --username 'johngage' 'database_name'

I expect the results to be redirected to file.txt because that is the
meta-command immediately preceeding the query.

In fact, the results go to stdout, obviously on account of the \o at
the end of the query. And, equally obviously, I can leave that out
(which "works").

But I am surprised that the \o is the controlling meta-command.

Thanks,

John

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David W Noon 2010-05-02 13:12:06 Re: Order of execution in shell echo to psql
Previous Message Mike Christensen 2010-05-02 11:59:25 Re: Indexing queries with bit masks