The Stream Processing Playbook
Pipes & Redirects β The Core of UNIX
The UNIX philosophy is: "Write programs that do one thing well. Write programs to work together." Pipes and redirects are HOW programs work together. Every DevOps engineer uses these dozens of times daily.
cmd1 | cmd2 β Pipe: stdout of cmd1 β stdin of cmd2cmd > file β Overwrite file with outputcmd >> file β Append output to filecmd 2> err.log β Redirect errors to filecmd > out.log 2>&1 β Capture EVERYTHING to one file
π Search & Filter
grep -iβ Case-insensitive searchgrep -rβ Recursive directory searchgrep -cβ Count matchesgrep -vβ Invert (exclude matches)grep -A 3β Show 3 lines after match
π Analyze & Count
wc -lβ Count linessort | uniq -cβ Count occurrencessort -rnβ Sort numerically (highest first)awk '{print $N}'β Extract column Nhead -N / tail -Nβ First/last N lines
β οΈ The Deadly Difference: > vs >>
> OVERWRITES β the file is completely replaced. Old content is gone forever.
>> APPENDS β new content is added at the end. Old content is preserved.
π Horror story: echo "new_var=true" > .env deleted 47 production environment variables. The engineer meant to use >>. Always double-check before pressing Enter!




