Command Prompt or cmd is the command-line interpreter on Windows NT, Windows CE, OS/2, and eComStation operating systems. It is a good tool to perform quick actions and make changes in system settings.
Sometimes, you need to save command output to maintain a record of your system’s health. You can copy and paste the commands anywhere but it is quite a hassle!
How to Save Command Prompt Output To A Text File
A Redirection operator command can save you from the inconvenience. A redirection operator is a special operator used with a command to redirect input or output of the command.
Here, we have listed a few Redirection operators to redirect command input and output streams.
Redirection operator | Description |
> | Redirects the command output to a file or a device, such as a printer, instead of the Command Prompt window. |
< | Reads the command input from a file, instead of reading input from the keyboard. |
>> | Appends the command output to the end of a file without deleting the information that is already in the file. |
>& | Writes the output from one handle to the input of another handle. |
<& | Reads the input from one handle and writes it to the output of another handle. |
|(Pipe) | Reads the output from one command and writes it to the input of another command. |
So this is the basic introduction and types of redirection operators. We will use only two of the Redirection Operators, greater-than sign, >, and the double greater-than sign, >> to perform the action.
Let’s have a look on examples to make you understand the concept better.
- ipconfig > Settings.txt
Ipconfig is a command which displays the network configuration, refreshes DHCP and DNS settings. Here, we have redirected the output of the command ipconfig to settings.txt file
Now, the output would be saved to the file name Settings.txt and if the file of such a name doesn’t exist, a new file would be created with the name. Moreover, the output would not be displayed on CMD screen.
- If you prefer to save the file to a location let’s say My Documents then use this command:
ipconfig > C:\Users\330001340\ Documents\Settings.txt
- To keep the records of an old command’s output and redirect the output of the recent command into the same file, use ‘>>’
ipconfig >> Settings.txt
The command would not overwrite the first output but appends the second output to it.
Now, you know how to save the output of a command of Command Prompt on a file and the best part is you can also can manipulate them anytime you want.