Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
QA interview question
InfrastructureJuniorOccasionalTheory

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.

#shell#pipeline#redirection#command-line

Sources

GNU Coreutils manualGNU Project · Linux and Unix-like filesystem, text, disk-usage and shell utility behaviorGNU grep manualGNU Project · Text search, matching options, recursive search and grep command semanticsPowerShell documentationMicrosoft · PowerShell cmdlets, object pipeline, processes, services, networking, event logs and environment handling