|
If a process reads from stdin but doesn't write to stdout, that process can only be used as the last process in a pipe.
If a process doesn't read from stdin but writes to stdout, that process can only be used as the first process in a pipe.
The pipe output is the result of the last process.
A tee in a pipe gives you intermediate results. Good for debugging pipes.
When a file is the target of a redirection, the first thing that happens is the next byte pointer is set to 0 (effectively emptying the file.) |
First, the NBP is set to 0. Then, sort sorts myfile (extremely quickly, for myfile is now empty!)
This process works differently in sh and csh.
csh is easy to do: