CMD Master
Back to Blog
•Arnošt Havelka

Streams & Piping

Master data flow with Redirection and Pipes.

Start Interactive Lesson
Streams & Piping

Every command in Windows has three standard "streams":

  1. STDIN (0): Standard Input (Keyboard)
  2. STDOUT (1): Standard Output (Screen)
  3. STDERR (2): Standard Error (Screen)

By manipulating these streams, you can save potential errors to a log file, chain commands together, or automate input.

Try the command

Redirect output to a file!

Build the command
dir[arguments]>[target]
Terminal
C:\Users\Student>dir > files.txt

Common Scenarios

1. The Pipe (|)

Passes the output of one command as input to the next.

Example: List files and find specific ones.

dir | find "txt"

2. Output Redirection (>) and (>>)

Save results to a file.

Example: Save ipconfig details.

ipconfig > network_info.txt

3. Error Redirection (2>)

Separate clean output from error messages.

Example: Hiding errors when deleting non-existent files.

del non_existent_file.txt 2> nul

(Sending to nul effectively discards the output)

Real-World Examples

1. Sorting Output

List text files and sort them by name.

Terminal
C:\Users\Student>dir /b *.txt | sort

2. Logging Errors Separately

Try to list a folder that doesn't exist, and save the error.

Terminal
C:\Users\Student>dir MissingFolder 2> errors.log

Knowledge Check

1 / 3

Which number represents Standard Error (STDERR)?

References

These documentation links provide authoritative details for the commands used in this article.

Up Next

Clip Command

Copy command output directly to your clipboard.