当使用 Windows 批处理命令追加到文件时,如何在文件中的下一个单词之后立即追加?
比如这些命令
echo here is the date of > c:\arun.txt
date /t >> c:\arun.txt
将以下文本写入arun.txt文件:
here is the date of
29-03-2010
但我希望输出是这样的:
here is the date of 29-03-2010
如何在追加时避免回车?
最佳答案
echo
输出始终包含尾随换行符。要输出没有尾随换行符的文本,您可以使用描述的 set/p
技巧 here和 here :
< nul (set /p s=Today is ) > c:\arun.txt
date /t >> c:\arun.txt
但在这种特定情况下,您可以简单地使用 %date%
变量代替 date/t
,因为 %date%
使用相同的格式:
echo Today is %date% > c:\arun.txt
关于windows - 使用 Windows 批处理命令追加到文件时,如何在文件中的下一个单词之后立即追加?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2539337/