从批处理文件创建空白文件
我想从批处理文件创建一个文件。我可以使用 echo。 > donald.txt,但它使用初始空行创建它。对于从第一行开始的文件,我还可以使用什么?
I would like create a file from a batch file. I can use the echo. > donald.txt
, but it creates it with an initial blank line. What else I can use to a file starting from the first line?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您只想创建一个完全空的文件?这样就可以了:
如果你想在第一行写一些东西,你想要这样的东西:
You just want to create a completely empty file? This will do it:
If you're looking to write something to first line, you want something like this:
其中一个选项
最初来自 http://www.netikka.net/tsneti/info/ tscmd041.htm 其中包含一些附加方法。
One of the options is
Originally from http://www.netikka.net/tsneti/info/tscmd041.htm which contains some additional methods.
在旧的 MS-DOS 时代,我使用这种方法创建一个空文件:
在新的 Windows 中,这不再有效,但
rem
可以被任何不显示任何内容的命令替换。例如:In old MS-DOS days I used this method to create an empty file:
In new Windows this no longer works, but
rem
may be replaced by any command that show nothing. For example:如果您使用的是 PowerShell:
来源:http://blog.lab49.com/archives/249。
If you're using PowerShell:
Source: http://blog.lab49.com/archives/249.
这是因为
echo.
在文件中插入一个空行。尝试使用相同的代码,但不要在
echo
语句末尾附加句点:That's because
echo.
inserts a blank line in your file.Try using the same code, but without the period appended to the end of the
echo
statement: