Input and output Redirection in Windows Command Prompt

Redirection allows you to send the output to files as well as get input from files.

Usually you get the input from standard input stream (console). But you can get the input from files as well. This is called as Input redirection. In below exmple, find command will first read the contents of xyz.txt and then display only those lines containing word “abc”.

find “abc” < xyz.txt

Usually any command sends output to standard output stream (console). But you can redirect the output to files as well. This is called as Output redirection. In below exmple, help command will send the output to commandhelp.txt file instead of console.

help > commandhelp.txt

Note that contents of file “commandhelp.txt” will be overwritten. If you want to append the content to this file, you can use below command.

help >> commandhelp.txt

You may also like...