Last Updated on April 1, 2020
Updated November 2022: Stop getting error messages and slow down your system with our optimization tool. Get it now at this link
- Download and install the repair tool here.
- Let it scan your computer.
- The tool will then repair your computer.
On Windows 10, the ability to save the output of a PowerShell or Command Prompt to a text file can be useful in many cases. For example, when you are solving a problem, it is a convenient way to export and analyze the results of the command, or you can share the results with someone who can help you. You can print the command output to a text file to save system configurations for documentation purposes, and much more.
Although you can simply select the content, right-click on the selection to copy the content to the clipboard, and then paste it into a text file, this method requires additional steps that you can avoid by using a single command line with the “Redirect Output to File” function.
In this Windows 10 guide, we walk you through the steps for saving the command output to a text file, whether you use the command prompt or PowerShell.
How to Save the Command Prompt Output to a Text File in Windows 10
If the output of an application is redirected with the “>” symbol, error messages are always printed on the display. This is because error messages are often sent to the standard error stream instead of the standard output stream.
The output of a console application (command prompt) or a command is often sent to two separate data streams. Regular output is sent to Standard Out (STDOUT) and error messages are sent to Standard Error (STDERR). If you redirect the console output with the “>” symbol, you redirect only STDOUT. To redirect STDERR, you must specify “2>” for the redirection icon. This will select the second output stream, which is STDERR.
To redirect the output of a command to a text file instead of printing it on the screen in the command window, just execute the command and add it with the “>” symbol in square brackets, which is called “redirection” accordingly.
For example, if you want to save the output of the DIR function in a text file instead of scrolling the screen page by page in the command window, you should use the
DIR > some-descriptive-filename.txt
like this, where we ran the DIR command from the C:\ directory and saved the output in the root directory of drive D as “c-drive-directory-output.txt”.
Note that the output is not displayed in the command window above, but when we open the text document, we see the full command output :
Any command having command window output (regardless of its size) can be joined with > filename.txt and the output is saved to the specified text file.
In addition to running the command once, you can also modify it slightly to copy the sequential output to the same text file. For example, suppose you want to send the output of the same command in the same text file before and after making some changes (for example, restarting the router and getting a new IP address). You can start the command first with a single angle bracket “>” and then repeat subsequent instances of the same command with a double angle bracket “>>”.
This allows us to store any number of order outputs in a text file for easy access or to share the information with others as needed.
Expert Tip: This repair tool scans the repositories and replaces corrupt or missing files if none of these methods have worked. It works well in most cases where the problem is due to system corruption. This tool will also optimize your system to maximize performance. It can be downloaded by Clicking Here
CCNA, Web Developer, PC Troubleshooter
I am a computer enthusiast and a practicing IT Professional. I have years of experience behind me in computer programming, hardware troubleshooting and repair. I specialise in Web Development and Database Design. I also have a CCNA certification for Network Design and Troubleshooting.