Problem Statement
What does the pipe (|) operator do?
Explanation
The pipe operator | connects the standard output of one command to the standard input of the next, enabling command chaining and data processing pipelines. Example: cat file.txt | grep 'pattern' | sort | uniq reads file, filters matching lines, sorts them, and removes duplicates. Each command processes data from previous and passes results to next.
Pipes work with any commands accepting stdin: ls -l | grep '.txt' lists only .txt files, ps aux | grep nginx finds nginx processes, cat access.log | awk '{print $1}' | sort | uniq -c counts requests per IP. Stderr isn't piped by default - use 2>&1 before pipe to include stderr: command 2>&1 | grep error.
Pipelines execute all commands concurrently, not sequentially. Exit status of pipeline is status of last command unless set -o pipefail enabled. Pipes enable powerful data processing without temporary files. Understanding pipes is fundamental to shell scripting and command-line efficiency, enabling complex operations through simple command composition.
