How to Redirect Windows Command Line Output to a Text File

Updated May 2024: Stop getting error messages and slow down your system with our optimization tool. Get it now at this link
  1. Download and install the repair tool here.
  2. Let it scan your computer.
  3. 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.

May 2024 Update:

You can now prevent PC problems by using this tool, such as protecting you against file loss and malware. Additionally it is a great way to optimize your computer for maximum performance. The program fixes common errors that might occur on Windows systems with ease - no need for hours of troubleshooting when you have the perfect solution at your fingertips:

  • Step 1 : Download PC Repair & Optimizer Tool (Windows 10, 8, 7, XP, Vista – Microsoft Gold Certified).
  • Step 2 : Click “Start Scan” to find Windows registry issues that could be causing PC problems.
  • Step 3 : Click “Repair All” to fix all issues.


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