Pipes
In this page:
Pipes
The pipe operator | connects the standard output of one command directly to the standard input of the next, letting you chain small commands into a data-processing pipeline. Bash runs both commands concurrently, streaming data between them. Pipelines are one of the most powerful and idiomatic features of shell scripting.
Note: Chain several pipes together, like cmd1 | cmd2 | cmd3, to build a multi-step data pipeline in one line.
Example: Pipes
#!/bin/bash
printf "banana\napple\ncherry\n" | sort
echo "---"
printf "a\nb\nc\nd\n" | wc -l
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 14 topics to unlock
0/14 topics done
Complete these topics first: