LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Having trouble with a simple script (https://www.linuxquestions.org/questions/linux-newbie-8/having-trouble-with-a-simple-script-604041/)

Arcturuss 12-02-2007 11:38 PM

Having trouble with a simple script
 
Hi guys, this is my first post.. starting with what is probably a rather newbie question:

I need to create a simple awk script to list current users logged on more than once.
So far I have

who | awk '{
logins[$1] = logins[$1] + 1
}
END {
for (i in logins)
print logins[i], i
}'

That lists the current users logged on and how many times they are logged on, but I need to use an 'if' statement to then show only the users logged on more than once.

Thanks in advance for any help :D

chrism01 12-03-2007 01:10 AM

Code:

if [[ $i -gt 1 ]]
then
    print logins[$i] $i
fi



All times are GMT -5. The time now is 06:17 AM.