test.sql contains a single SELECT command and when I run that file I see the result of the select command.. The problem is, I also want to see the SELECT command itself.
I've tried /echo /qecho and a lot of other commands, but nothing works.
If set to all, all nonempty input lines are printed to standard output as they are read. (This does not apply to lines read interactively.) To select this behavior on program start-up, use the switch -a. If set to queries, psql prints each query to standard output as it is sent to the server. The switch for this is -e. If set to errors, then only failed queries are displayed on standard error output. The switch for this is -b. If unset, or if set to none (or any other value than those above) then no queries are displayed. "
aklaver@panda:~> cat psql_test.sql select * from a ;
aklaver@panda:~> psql -a -d test -U postgres -h localhost psql (9.4.6) SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off) Type "help" for help.