LINUX / A CONCEPT NOTE
Pipes & Redirection
how commands chain
Overview · mechanism
pitfall · examples
01 / THE SHORT VERSION
The idea in a few sentences.
Linux processes communicate by default via three standard files: stdin (0), stdout (1), and stderr (2). Pipes (|) redirect the stdout of one command to the stdin of the next.
02 / FOLLOW THE MECHANISM
How redirection flows
Process A
runs and outputs text to its standard output (stdout).
Pipe (|)
kernel catches this stream and feeds it directly into Process B's standard input (stdin).
Process B
processes the input and writes its results to stdout.
File redirect (>)
writes the final output to a file on disk, overriding its contents.
04 / COMMAND NOTES
Read the command, then the result.
Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.
grep for error messages in a log file
cat logs.txt | grep -i errorappend text to a file without deleting existing contents
echo \"new log\" >> output.log05 / CHECK YOURSELF
Could you explain Pipes & Redirection to a teammate?
Try it out loud in two sentences: what it is, and the one detail that changes the picture. If you stall, the gap is the part to reread.
Up next in Linux & systemsEnvironment Variableswhere config hides