Manchmal kann es erwünscht sein, die Ausgaben eines Programms in eine Datei zu schreiben, die Fehlerausgaben aber über eine Pipe weiterzufiltern, und dennoch die Ausführung im Hintergrund stattfinden zu lassen.
Folgender Codeschnipsel verwendet
$ (cmd 3>&1 > ausgabedatei 2>&3 3>&- ) | mail -s "errors aus cmd" &
| Function | csh | sh |
|---|---|---|
| Send stdout to file | prog > file | prog > file |
| Send stderr to file | prog 2> file | |
| Send stdout and stderr to file | prog >& file | prog > file 2>&1 |
| Take stdin from file | prog < file | prog < file |
| Send stdout to end of file | prog » file | prog » file |
| Send stderr to end of file | prog 2» file | prog 2» file |
| Send stdout and stderr to end of file | prog »& file | prog » file 2>&1 |
| Read stdin from keyboard until c | prog «c | prog «c |
| Pipe stdout to prog2 | prog | prog2 | prog | prog2 |
| Pipe stdout and stderr to prog2 | prog |& prog2 | prog 2>&1 | prog2 |