LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-02-2007, 11:38 PM   #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, 01:10 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 18,237

Rep: Reputation: 2711Reputation: 2711Reputation: 2711Reputation: 2711Reputation: 2711Reputation: 2711Reputation: 2711Reputation: 2711Reputation: 2711Reputation: 2711Reputation: 2711
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 03:45 AM
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 04:19 AM
Need help with a simple script shell script WindowBreaker Linux - Software 2 12-15-2005 12:45 PM
Simple installation: having some trouble mixedmemes Linux - Software 1 05-11-2005 03:59 PM
Simple C Shell script is not so simple elconde Programming 2 09-16-2001 11:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:21 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
Open Source Consulting | Domain Registration