Sure, psql has options for input query and output:
psql database <inquery >output.
> hello oh-more-knowledgable-than-me postgres folks!
>
> i'd like to run a select statement tonight after everyone is gone, and i
> don't feel like coming back in to do it (last person gone at 11pm). i need
> the output saved to a file, if possible. how can i do it from the bash
> prompt?? (linux rh 5.2, pg 6.4.2)
>
> jt kirkpatrick / mps
>
> ************
>
>
--
Bruce Momjian | http://www.op.net/~candle
[EMAIL PROTECTED] | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
************