Order of execution in shell echo to psql - Mailing list pgsql-general

From John Gage
Subject Order of execution in shell echo to psql
Date
Msg-id 857721FD-7443-4B3E-A06E-FA3D8FDF0573@numericable.fr
Whole thread Raw
Responses Re: Order of execution in shell echo to psql  (David W Noon <dwnoon@ntlworld.com>)
List 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

pgsql-general by date:

Previous
From: AI Rumman
Date:
Subject: int2vector
Next
From: David W Noon
Date:
Subject: Re: Order of execution in shell echo to psql