Files and Pipelines
Pipelines
Connecting Commands
A pipeline sends stdout from one command into stdin of the next. Each command does one small job.
Program
Play the script to see generated log text flow into grep.
pipelines.sh
#!/usr/bin/env bash
log=$'error\nok\nerror'
matches="$(printf '%s\n' "$log" | grep -c error)"
echo "matches=$matches"
pipeline
`cmd1 | cmd2` connects the first command's stdout to the second command's stdin.
filter
A filter reads input, selects or transforms it, and writes a result.