psql is a terminal-based front-end to PostgreSQL. It enables you
to type in queries interactively, issue them to PostgreSQL, and
see the query results. Alternatively, input can be from a file.
In addition, it provides a number of meta-commands and various
shell-like features to facilitate writing scripts and automating
a wide variety of tasks. Print all input lines to standard
output as they are read. This is more useful for script
processing rather than interactive mode. This is equivalent to
setting the variable ECHO to all. Switches to unaligned output
mode. (The default output mode is otherwise aligned.) Specifies
that psql is to execute one command string, command, and then
exit. This is useful in shell scripts. command must be either a
command string that is completely parsable by the server (i.e.,
it contains no psql specific features), or a single backslash
command. Thus you cannot mix SQL and psql meta-commands. To
achieve that, you could pipe the string into psql, like this:
echo "\x \\ select * fro