As an internal command psql, and like other commands starting with a backslash, it \copyshould fit on one line.
, - .
COPY \copy, STDOUT stdout . :
$ psql -At -d test <<EOQ >outfile
COPY
(select 1,2
union
select 3,4)
TO STDOUT;
EOQ
:
$ cat outfile
1 2
3 4
psql, COPY , :
test=> \t
Showing only tuples.
test=> \o outfile
test=> copy
test-> (select 1,2
test(> union
test(> select 3,4)
test-> to stdout;
test=> \o
test=> \t
Tuples only is off.
\o outfile , \o .