I want to export a string for a bash script. The terminal is naturally very picky when it comes down to the "\n\r" vs "\n", Windows vs. Linux, new line issue.
How can I teach Mathematica to use "\n" rather than "\n\r" as the line separator when exporting text (in Windows)?
I found a couple of posts regards the same issue, but they were concerned with importing files. For example, here. None of the suggested solutions worked for my case.
I played with CharacterEncoding
and "LineSeparators"
but nothing worked.
EDIT:
Great thanks to Mark Adler for giving me the right clue.
His suggested solution WriteString[f, "\n"]
did not work because "\n" is interpreted by Mathematica as string not as end-of-line.
However, his suggested DOSTextFormat -> False
option also works as option for Export[]
.
I got the desired result using Export[filename,script,"Text",DOSTextFormat -> False]
.