I'm exporting using vsql and I've included an explicit ' \pset recordsep '\n' ' in the header.
I'd expect the resulting text file to have just 'LF' at the end of each record, but the records end in 'CRLF' instead, despite the lack of '\r' in the record separator. This is a problem for me, as I need the exported file not to have '\r' characters. I am running Windows.
Has anyone else run into this problem? I couldn't find anything related in the vsql documentation.
I tried using
\012
(octal for newline) and it equates that with\n
so I don't see a way to do it withinvsql
.You could download a program from Sourceforge called dos2unix.exe and pipe it, something like:
Also, a second thought... if you are transferring this output file to a unix server, then instead you can transfer it in
ASCII mode
which with automatically translate theCRLF
for you. Some clients will automatically do it based upon the file extension (usually labeled asAutomatic mode
), but regardless of the file extension, you should be able to set it specifically for FTP, SFTP or even SCP on some clients. Be aware that for SCP, it will have to convert it BEFORE the transfer due to the SCP protocol requirement of knowing the exact file size before the transfer even starts.