I'm learning UNIX and I have a simple question

Leslie Mikesell les at chinet.chi.il.us
Fri Jun 21 02:37:39 AEST 1991


In article <jpope.677361841 at sysp1> jpope at hq.af.mil (i991x) writes:

>One of the things I am currently learning is "pipes" and "redirected output."
>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.

Recent sysV's have a -q option to just give names and a -n number option
to control how many names per line to show with the -q option.  But there
are any number of ways to manipulate the output from a program into
what you want to see, and you should learn at least a few of them. Awk,
sed and the shell itself are the most general, pr has some options for
columns and formatting.

/bin/sh or ksh 
who |
 (while read A B
 do
 echo $A
 done) | pr -t -4


Les Mikesell
  les at chinet.chi.il.us



More information about the Comp.unix.questions mailing list