Pipes
To see who is on the system
with you, type
% who
One method to get a sorted list
of names is to type,
% who > names.txt
% sort < names.txt
This is a bit slow and you have
to remember to remove the
temporary file called names when
you have finished. What you really
want to do is connect the output
of the who command directly to the
input of the sort command. This is
exactly what pipes do. The symbol
for a pipe is the vertical bar |
For example, typing
% who | sort
will give the same result as
above, but quicker and cleaner.
To find out how many users are
logged on, type
% who | wc -l
Example
Using pipes, display all lines
of list1 and list2 containing the
letter 'p', and sort the result.
% cat list1 list2 | grep p | sort
|