Why does the
who > lp creates a file but
who | lp leads the output to program
What is the underlying principle behind these two simple commands? Can somebody explain it with an example?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
> is redirection to a file.
| is a redirection to a process through the use of a pipe.
The latter essentially points file descriptor 1 (
STDOUT) of one process to a pipe which leads to file descriptor 0 (
STDIN) of another process. A file redirection operation is not as complex, it merely takes an FD and dumps it to a file.