| command > file | Write standard output of command to file |
| command 1> file | Write standard output of command to file (same as previous) |
| command 2> file | Write standard error of command to file |
| command > file 2>&1 | Write both standard output and standard error of command to file |
| command >> file | Append standard output of command to file |
| command 1>> file | Append standard output of command to file (same as previous) |
| command 2>> file | Append standard error of command to file |
| command >> file 2>&1 | Append both standard output and standard error of command to file |
| commandA | commandB | Redirect standard output of commandA to standard input of commandB |
| commandA 2>&1 | commandB | Redirect standard output and standard error of commandA to standard input of commandB |
| command < file | command gets standard input from file |
| command 2>&1 | command's standard error is redirected to standard output |
| command 1>&2 | command's standard output is redirected to standard error |
| ECHO Hello world>NUL | Redirect Standard Output stream to the NUL device |
| EHCO Hello world 2>NUL |
Redirect Standard Error stream to the NUL device. Note: "EHCO" spelling error is intentional. |
| ECHO Hello world > NUL 2>&1 |
Redirected Standard Output and Standard Error to the NUL device |
| ECHO Hello world > hello.txt 2>&1 |
Redirect Standard Output and Standard Error to a file |
| test.bat > testlog.txt 2> testerrors.txt |
Redirect Standard Output to testlog.txt and Standard Error to testerros.txt. |
| ECHO Hello world>CON |
Redirect Output to screen no matter what. Even if the script's output is redirected. |
Creat the batch file on the left below, execute it form the command line and
redirect the ouput: