The -o flag sends query results to out.txt instead of the terminal, handy in scripts. Combine with -A -t for clean machine-readable files. Related: \o inside psql does the same.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.