Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2012
    Posts
    2

    Question Unanswered: psql output to text file: how to output linebreaks between records?

    Hi All,

    I have a psql command that outputs data to a textfile (on Windows):
    Code:
    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?

    Any help would be appreciated!

    Best regards,
    Martijn Senden.

  2. #2
    Join Date
    Jan 2012
    Posts
    2

    Smile Solved, but...

    Hi All,

    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:
    Code:
    -R $'\r\n'
    This doesn't work for windows though. If you have any ideas...

    Best regards,
    Martijn Senden.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •