Andy Shellam (Mailing Lists) wrote:
Hi Enrico,
The following command will get you a text file of your result-set:
# echo "SELECT customer_id, first_name, sur_name FROM
users;"|/usr/local/pgsql/bin/psql -U [username] -d [database] > myfile.txt
# cat myfile.txt
Alternative version:
psql -d <your dbname> -c "SELECT customer_id, first_name, sur_name FROM
users" -o myfile.txt
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq