Software & Apps Windows 136 136 people found this article helpful How to Redirect Command Output to a File Use redirection operators to save a command's results to a file by Tim Fisher General Manager, VP, Lifewire.com Tim Fisher has 30+ years' professional technology support experience. He writes troubleshooting content and is the General Manager of Lifewire. our editorial process Facebook Twitter LinkedIn Tim Fisher Updated on April 05, 2020 reviewed by Jerrick Leger Lifewire Tech Review Board Member Jerrick Leger is a CompTIA-certified IT Specialist with more than 10 years' experience in technical support and IT fields. He is also a systems administrator for an IT firm in Texas serving small businesses. our review board Article reviewed on Apr 30, 2020 Jerrick Leger Windows The Ultimate Laptop Buying Guide Tweet Share Email Use a redirection operator to redirect the output of a command to a file. It's one of our favorite Command Prompt Tricks & Hacks. All the information that's displayed in the Command Prompt after running a command can instead be saved to a file which you can open in Windows to reference later or manipulate however you like. While there are several redirection operators, which you can read in detail about here, two, in particular, are used to output the results of a command to a file: the greater-than sign, >, and the double greater-than sign, >>. How to Use Redirection Operators The easiest way to learn how to use these redirection operators is to see some examples: ipconfig /all > mynetworksettings.txt Redirecting 'ipconfig' Results to a TXT File. In this example, all the network configuration information normally seen on screen after running ipconfig /all, is saved to a file by the name of mynetworksettings.txt. It's stored in the folder to the left of the command, C:\Users\jonfi in this case. The > redirection operator goes between the ipconfig command and the name of the file. If the file already exists, it'll be overwritten. If it doesn't already exist, it will be created. Although a file will be created if doesn't already exist, folders will not. To save the command output to a file in a specific folder that doesn't yet exist, first, create the folder and then run the command. Make folders without leaving Command Prompt with the mkdir command. ping 10.1.0.12 > "C:\Users\jonfi\Desktop\Ping Results.txt" Redirecting "ping" Results to a TXT File in a Different Folder. Here, when the ping command is executed, Command Prompt outputs the results to a file by the name of Ping Results.txt located on the jonfi user's desktop, which is at C:\Users\jonfi\Desktop. The entire file path in wrapped in quotes because there was a space involved. Remember, when using the > redirection operator, the file specified is created if it doesn't already exist and is overwritten if it does exist. The Append Redirection Operator The double-arrow operator appends, rather than replaces, a file: ipconfig /all >> \\server\files\officenetsettings.log Appending "ipconfig" Results to an Existing LOG File. This example uses the >> redirection operator which functions in much the same way as the > operator, only instead of overwriting the output file if it exists, it appends the command output to the end of the file. Here's an example of what this LOG file might look like after a command has been exported to it: A LOG File of Command Prompt Results. The >> redirection operator is useful when you're collecting similar information from different computers or commands and you'd like all of that data in a single file. The above redirection operator examples are within the context of Command Prompt, but you can also use them in a BAT file. When you use a BAT file to pipe a command's output to a text file, the exact same commands described above are used, but instead of pressing Enter to run them, you just have to open the .BAT file. Use Redirection Operators in Batch Files Redirection operators work in batch files by including the command just as you would from the Command Prompt: @ECHO OFF:: Output 'tracert' to a text file.TITLE Tracert Logtracert yahoo.com > Z:\yahootracert.txt The above is an example of how to make a batch file that uses a redirection operator with the tracert command. The yahootracert.txt file (shown above) will be created on the Z: drive several seconds after executing the sample.bat file. Like the examples above, the file shows everything Command Prompt would have revealed if the redirection operator wasn't used.