A redirection operator is a special character that can be used with a command, like a Command Prompt command or DOS command, to either redirect the input to the command or the output from the command.
By default, when you execute a command, the input comes from the keyboard and the output is sent to the Command Prompt window. Command inputs and outputs are called command handles.
Redirection Operators in Windows and MS-DOS
The table below lists all the available redirection operators for commands in Windows and MS-DOS. However, the > and » redirection operators are, by a considerable margin, the most commonly used.
Two other redirection operators, >& and <&, also exist but deal mostly with more complicated redirection involving command handles.
The clip command is worth mentioning here as well. It’s not a redirection operator but it is intended to be used with one, usually the vertical pipe, to redirect the output of the command before the pipe to the Windows clipboard.
For example, executing ping 192.168.1.1 | clip will copy the results of the ping command to the clipboard, which you can then paste into any program.
How to Use a Redirection Operator
The redirection operator is added after the normal command is written.
The ipconfig command is a common way to find various network settings through Command Prompt. One way to execute it is by entering ipconfig /all in the Command Prompt window.
When you do that, the results are displayed within Command Prompt and are then only useful elsewhere if you copy them from the Command Prompt screen. That is unless you use a redirection operator to redirect the results to a different place like a file.
Ipconfig Command Redirection Operator
ipconfig /all > networksettings.txt
If we look at the first redirection operator in the table above, we can see that the greater-than sign can be used to send the command’s results to a file. This example command above is how you’d send the results of ipconfig /all to a text file called networksettings.txt.
Dir Command Redirection Operator
The dir command is another situation where a redirection operator is really useful. Since that command often produces results too long to read comfortably in a Command Prompt window, exporting all of it to a text document is wise.
dir C:\Users\Tim\Downloads > downloads.txt
In that example, all files and folders in that user’s Downloads folder will be shown in the downloads.txt file.
The TXT file is saved in the same folder the command is executed from, not necessarily the folder used in the command. In this example, if the command runs from Users\Tim, the downloads.txt file will be saved there, not in Tim\Downloads.
Get the Latest Tech News Delivered Every Day
How to Redirect Command Output to a File
How to Use the Netstat Command on Mac
The Complete List of Command Prompt (CMD) Commands
21 Best Command Prompt Tricks
How to Use the Netstat Command
What Is an EX_ File?
More Command
How to Verify File Integrity in Windows With FCIV
Net Send Command
How to Open Command Prompt (Windows 11, 10, 8, 7, etc.)
Vol Command Examples and Options
Windows 8 Command Prompt Commands
Windows 7 Command Prompt Commands
How to Open an Elevated Command Prompt
How to Restore Deleted Files From the Recycle Bin
How to Use the Tracert Command in Windows
Facebook
Twitter
Hit Refresh on Your Tech News
About Us
Privacy Policy
Editorial Guidelines
Terms of Use
Careers
Advertise
Contact
EU Privacy
NEWS
HOW TO
FEATURES
ABOUT US