I am trying to show how many users are logged into one of my systems. Using who -q it gives me a user count, but some users are logged in multiple times.
Is there any easy parameter that I can use to ignore/eliminate these duplicates??
Thanks
I am trying to show how many users are logged into one of my systems. Using who -q it gives me a user count, but some users are logged in multiple times.
Is there any easy parameter that I can use to ignore/eliminate these duplicates??
Thanks
Can you try with who|uniq , see whether you are get rid of dups.
Cheers,
gehlnar
No... no joy :-(,
who|uniq outputted exactly the same as the who command without the pipe.
who | awk '{ print $1 }' | sort -u
Hi,
This one also can help.
who | awk '{print $1}' | uniq
who | cut -f1 -d' ' | sort | uniq
Thanks, that has listed all the unique users, how would I then calculate the amount of users, like who -q shows #users... any thoughts?
who -q | wc -w
This should give the number of unique users:
who|awk '!a[$1]++{print $1;i++}END{print "users = "i}'
Regards
Just pipe any of the previous solutions to wc -l, for example:
who | awk '{ print $1 }' | sort -u | wc -l