문제

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
도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top