Skip to main content
LESSON 2 of 5//Stream Processing

Piping with |

The pipe operator | connects the stdout of one command to the stdin of the next. This is the Unix philosophy in action — small, focused tools chained together to accomplish complex tasks.

Building pipelineszsh // interactive
# Count files in a directory
~ls | wc -l
12
# Find TypeScript files and count them
~find . -name '*.ts' | wc -l
47
# Chain multiple pipes
~cat server.log | grep 'ERROR' | sort | uniq -c | sort -rn
42 ERROR: Connection timeout
15 ERROR: Auth failed
3 ERROR: Out of memory

The Unix philosophy

"Write programs that do one thing and do it well. Write programs to work together." — Doug McIlroy. Pipes are what make this philosophy practical.

PRACTICE//Try the commands from this lesson
INTERACTIVE_TERMINAL//sandbox
Practice terminal — try the commands from this lesson!
Type 'help' for available commands. Tab completion not available in simulator.
Try: