I am writing this batch program, that writes to a text file to store data that will be used later on. The thing is when I recall my data it only takes the last line of the text file. The problem is that every time I add data it adds the data on a new line, so I only get the last input back. Is there a way that I can add data to a text document, without adding it on a new line?
我正在编写这个批处理程序,它写入一个文本文件来存储稍后将使用的数据。问题是,当我回想起我的数据时,它只需要文本文件的最后一行。问题是,每次我添加数据时,它都会在新行上添加数据,因此我只返回最后一个输入。有没有办法可以将数据添加到文本文档,而无需在新行上添加?
1 个解决方案
#1
1
Redirection doesn't matter at all. You can suppress the line break the same way you would when writing to the screen via set /p
:
重定向根本不重要。您可以通过set / p写入屏幕时的方式抑制换行:
< nul >> foo.txt set /p _=Some text.
echo
will of course always add a line break after the written line.
echo当然总是在写入行后添加换行符。
#1
1
Redirection doesn't matter at all. You can suppress the line break the same way you would when writing to the screen via set /p
:
重定向根本不重要。您可以通过set / p写入屏幕时的方式抑制换行:
< nul >> foo.txt set /p _=Some text.
echo
will of course always add a line break after the written line.
echo当然总是在写入行后添加换行符。