Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!asuvax!ncar!hsdndev!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.unix.questions Subject: Re: I'm learning UNIX and I have a simple question Message-ID: <16470@smoke.brl.mil> Date: 20 Jun 91 18:03:52 GMT References: Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 26 In article jpope@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.