From: Geoff Clare on
Ben Bacarisse wrote:

> If the OP is counting users, w -h is better. I'd be tempted to write:
>
> W=$(who -q)
> W=${W#*users=}
>
> but I don't know how portable the output from who -q is.

POSIX/SUS doesn't specify the output format for -q. It just says
"List only the names and the number of users currently logged on."
I don't think you can even count on the number of users being the
last field in the output.

If you meant portable in practice, rather than portable according to
the standards, then it may well be reasonably portable. I tried it
on three different systems and they all output the same format.

--
Geoff Clare <netnews(a)gclare.org.uk>