Is there any way to have this:
echo test line > t.txt
run in a windows batch file or makefile use a unix line ending (\n
) instead of a windows one (\r\n
)?
Is there any way to have this:
echo test line > t.txt
run in a windows batch file or makefile use a unix line ending (\n
) instead of a windows one (\r\n
)?
Combining answers from here Windows batch: echo without new line and here Is it possible to put a new line character in an echo line in a batch file?
SET LF=^
REM important to have two blank lines after the SET command
<NUL set /p=test line^%LF%%LF%> t.txt
No, you can't do it using echo
. Echo
works by simply writing a line of text followed by a CR/LF pair (the Windows line ending characters). Redirecting to a file just sends that line of text to a file handle instead of stdout
. There's no way to modify the line ending characters used.