Pipes
Cheat sheet · https://pcornel.dk/topic.php?topic=2684
Answer
A pipe (|) connects one command's stdout to the next command's stdin, so commands run together as a pipeline.
Remember
The pipeline's exit status is the last command's, so earlier failures are hidden — use set -o pipefail. stderr is not piped unless you add 2>&1 (or |&). Commands in a pipeline run in subshells, so variables set there are lost.
First checks
bash -x script.sh— trace each expanded commandbash -n script.sh— syntax check onlyshellcheck script.sh— common bugs and quoting problemsecho $?— exit code of the last command
Verify in this order
command 1 writes to stdout → pipe buffer → command 2 reads stdin → … → last command's exit code (or first failure with pipefail)
Where it usually breaks
First mismatch in persistent intent → provider/parser/generator → kernel/userspace runtime → dependency/security context → logs/counters → consumer-visible read-back; preserve identity/native diagnostic/pre-state before mutation.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2684