Question

I've got a Cygwin script that outputs stuff to a file. My only problem is that it always uses the \n "lf" line endings instead of \r\n "cr-lf". I want to either replace them or just get cygwin to always output \r\n for line endings.

I've tried the following two commands to no avail within the script.

unix2dos d:/temp.txt
sed -i -e 's/\n/\r\n/g' d:/temp.txt
Was it helpful?

Solution

You're specifying the path to unix2dos using a bizarre mix of Windows and Linux file endings.

If you're calling it from a Windows command shell, use this:

unix2dos d:\temp.txt

If you're calling it from within Cygwin, or a Cygwin shell script or similar, use this:

unix2dos /cygdrive/d/temp.txt

OTHER TIPS

Your unix2dos call should work. Are you getting some kind of error?

The Cygwin installer has an option for selecting the default line ending convention (DOS or Unix), although it might only show it during a new installation -- I don't remember offhand.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top