Unanswered: psql output to text file: how to output linebreaks between records?
I have a psql command that outputs data to a textfile (on Windows):
psql -a -d somedb -h somehost -U someuser -c "select * from someschema.sometable;" -A -F ; -R \r\n -o "c:\somefile.txt"
Now this outputs the data with \r\n as a literal string in the text between each record. What I need is to have each record start on an actual new line, with a 'hard return' between them. Can this be achieved using psql from the command line?
Well, sometimes solutions can be so easy you just overlook them. The default behaviour for psql is to use a newline (\n) between each record. This was fine for me, I just started using -R right from the start and couldn't find the right value. I'm still curious what it is though. I might be happier if I would be able to use a \r\n. I did read somewhere that on Linux you can do:
This doesn't work for windows though. If you have any ideas...