Hi, All -
How can I use "grep -c" command with finger/who (or some other Unix command) in order to figure out number of users currently on the system excluding the user ids starting with a/A.
(NOTE): User ids starting with a/A are the administrators. I am only interested to find out number of users connected to my system.
Thanks in advance!
Scott
July 7, 2009, 2:23pm
2
who | grep -cv "^[aA]"
or is a/A the actual start of the username?
who | grep -cv "^a/A"
SCOTTN, thanks for your reply.
The following command is working for me except for one thing. It is including the first line in the count:
Login Name TTY Idle When Where
$ finger | grep -cv '^[Tt]'
17
Is there a way to exclude the first line as well?
Scott
July 7, 2009, 3:23pm
4
Hi.
Yes. Finger has a header line that you need to remove.
finger | grep -Ecv '^Login|^[Tt]'
should do it.
SCOTTN <<< Thanks again.
Worked like a ~charm~.
Following command works as well.
finger | egrep -cv '^Login|^[Tt]'
Scott
July 7, 2009, 3:40pm
6
The e stands for "extended"... some systems may not have egrep. grep -E does much the same thing.
It's like nawk and gawk. Why use them if a) awk exists and; b) it does enough for you?
Use below commands...
who | grep -cv '^[aA]'
finger | grep -cv '^Login|^[aA]'