TOPIC LINUX
Pipes & Redirection how commands chain
IN 10 SECONDS
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.
GOTCHA The '>' operator replaces the destination file completely. To append output instead of wiping the file, use '>>' instead.
HOW REDIRECTION FLOWS
01 Process A runs and outputs text to its standard output (stdout).
02 Pipe (|) kernel catches this stream and feeds it directly into Process B's standard input (stdin).
03 Process B processes the input and writes its results to stdout.
04 File redirect (>) writes the final output to a file on disk, overriding its contents.
POKE IT YOURSELF
cat logs.txt | grep -i error — grep for error messages in a log file
echo \"new log\" >> output.log — append text to a file without deleting existing contents
Drill this topic →
~65 sec read