What do pipes and output redirection do in a command shell?
Answer
A pipe sends one command's standard output to another command's standard input, while redirection sends standard output or standard error to a file or another target. In common Unix shells, `>` overwrites a file, `>>` appends, `2>` redirects standard error and `|` creates a pipeline. The exact syntax differs in PowerShell because its pipeline normally transports objects.
Strong answer includes
- pipe connects producer output to consumer input
- distinguishes overwrite, append and stderr redirection
- does not assume every shell pipeline has identical semantics
Practical example
`grep -i error app.log | tail -n 20 > latest-errors.txt` filters matching lines, keeps the last twenty, and writes the result to a file instead of only displaying it in the terminal.