简体   繁体   English

将批处理文件的输出保存在命令提示符下

[英]Saving the output of a batch file in command prompt

Is there anyway to write the command windows output to a file? 无论如何,将命令窗口输出写入文件? To have a transcript if you will. 如有需要,请提供成绩单。

Yes, for example, on the command prompt you can do this: 是的,例如,在命令提示符下,您可以执行以下操作:

dir *.* > c:\temp\a.txt

This operation is called 'output redirection'. 此操作称为“输出重定向”。 The output of the above command will go the named file and will overwrite it if it already exists with the results. 上面命令的输出将进入命名文件,如果结果已经存在,则将其覆盖。 You can find many examples on the net for that, example: Redirection. 您可以在网上找到许多示例,例如: 重定向。

In command prompt, use >> operator. 在命令提示符下,使用>>运算符。

For example, If you type below command then output will be saved to output.txt file 例如,如果键入以下命令,则输出将保存到output.txt文件

dir > output.txt 目录> output.txt

If you type below then output will be appended to exist file. 如果在下面键入,则输出将附加到现有文件中。

dir >> output.txt 目录>> output.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM