Best way to execute sql scripts using psql
How to clear your screen in a psql session:
Run a bunch of sql commands in a single transaction.
Shell script to dump contents of bytea column to a file
Using the PG* environmental variables to make your shell scripts more terse.