有没有办法解决这个问题:
echo test line > t.txt
在Windows批处理文件或makefile中运行使用unix行结尾(\n
)而不是windows one(\r\n
)?
答案 0 :(得分:1)
不,你不能使用echo
来做。 Echo
只需编写一行文本后跟一个CR / LF对(Windows行结束符)即可。重定向到文件只会将该行文本发送到文件句柄而不是stdout
。无法修改使用的行结束字符。
答案 1 :(得分:1)
结合此处Windows batch: echo without new line和此处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