Pipelines
pipeline
command1 | command2 ...
time [-p] command1 [| command2 ...]
- the output of each command is connected to the inpot of the next command
- the exit code of the pipe is the exit code of the last command
- if a exclamation mark (!) precedes the first command of the pipe, the exit status of the pipe will be negated
- every command is executed as a separate process (i.e. in a subshell)
Example (patching a sourcetree):
zcat patchfile.gz | patch -p1
Example (emulation of man)
zcat nice.1.gz | groff -T ascii -m an | less
FIXME: um keine Steuerzeichen im Output zu haben...
Example (counting the shells in /etc/shells)
cat /etc/shells | grep "/bin" | wc -l # UUCA
grep "/bin" /etc/shells | wc -l