LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-03-2007, 12:38 AM   #1
Arcturuss
LQ Newbie
 
Registered: Dec 2007
Posts: 1

Rep: Reputation: 0
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
 
Old 12-03-2007, 02:10 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Code:
if [[ $i -gt 1 ]]
then
    print logins[$i] $i
fi
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple script to wait for another script Maverick1182 Linux - Newbie 4 11-05-2007 04:45 AM
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 05:19 AM
Need help with a simple script shell script WindowBreaker Linux - Software 2 12-15-2005 01:45 PM
Simple installation: having some trouble mixedmemes Linux - Software 1 05-11-2005 04:59 PM
Simple C Shell script is not so simple elconde Programming 2 09-17-2001 12:53 AM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration