I'm learning UNIX and I have a simple question

Doug Gwyn gwyn at smoke.brl.mil
Fri Jun 21 04:03:52 AEST 1991


In article <jpope.677361841 at sysp1> jpope at hq.af.mil (i991x) writes:
>In the UNIX that I use there is a command "who" which lists the users that
>are currently on the system (as well as which terminal, when they logged on,
>etc..).  The problem is that they are listed one user per line.
>I would like to strip off the first field (the id-name) and output to the
>screen four columns (four users per line instead of one) without the other
>information about where and when they logged in.

	who | awk '{print $1}' | sort -u | 4

where "4" is one of several links ("2" through "6") to the same
executable shell script that I maintain in one of the command directories:

	exec pr -t -w80 -`basename $0` $*

You can of course substitute "pr -t -w80 -4" for "4" in the above pipeline,
if you'd rather do that than create the useful commands "2" through "6".

There are other variations, using other commands to do essentially the
same jobs.  The commands are described in the UNIX user reference manual
in section 1; on many implementations one can also print a copy of the
manual entry on-line via the "man" command, as in "man 1 sort".

This example of exploiting the UNIX user environment is prototypical.
The first half of Kernighan and Pike's "The UNIX Programming Environment"
does a good job of teaching how to devise these things for yourself.



More information about the Comp.unix.questions mailing list