Show the login of users connected with awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Show the login of users connected with awk
# 1  
Old 10-19-2010
Show the login of users connected with awk

Hello everyone, I was trying to get the all logins of the users connected with awk, using "w" command,

I probe with this:

w|awk 'NR>2 {print $1}'

But I'm not sure...

is it ok?

Thank You so much!
# 2  
Old 10-19-2010
It seems to be OK:

Code:
$ w|awk 'NR>2 {print $1}'
scott
scott

Do you have a problem with it?

Perhaps a slight modification:
Code:
$ w|awk 'NR>2 && !A[$1]++ {print $1}'
scott

# 3  
Old 10-20-2010
Quote:
Originally Posted by scottn
It seems to be OK:

Code:
$ w|awk 'NR>2 {print $1}'
scott
scott

Do you have a problem with it?

Perhaps a slight modification:
Code:
$ w|awk 'NR>2 && !A[$1]++ {print $1}'
scott

I got the true secuence command, anyway thank you for your help!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to show a list of currently logged in and logging out users?

Hi Guys! I am sure that this question might appeared previously, but I still don't know how to show a list of logged out users. Please help with this! Thanks in advance:) (5 Replies)
Discussion started by: saloliubliu
5 Replies

2. Red Hat

Cannot show graphical login display

Hi all, I'm running Red Hat Enterprise Linux Server 6.3 Santiago. I already installed the X Window package during installation and the graphical login display can be shown normally after installation. Yesterday, I accessed remotely by GUI mode using VNC viewer and somehow it got crashed.... (1 Reply)
Discussion started by: sergionicosta
1 Replies

3. Solaris

Passwordless Login between users

Hi Gurus, Wanted to know if there is a way to enable passwordless login between specific users in a Solaris (5.9)server. I copied the public key of first user into the $HOME/.ssh/authorized_keys file of the second user. But it didn't work out. Note - Am talking about users in the same... (9 Replies)
Discussion started by: Hari_Ganesh
9 Replies

4. HP-UX

No users can login

Dear Forum, I had this case before, all of sudden all users including root can't login. What done is by connecting to console port and resetting root password, "pwunconv" command, reboot server. My question is, how this can happen??? thanks :confused: (3 Replies)
Discussion started by: irda
3 Replies

5. AIX

How to show hostname infor after login

When I login AIX console, how to show hostname before any command: hostname:/#>id uid=0(root) gid=0(system) groups=2(bin),3(sys),7(security),8(cron),10(audit),11(lp) (15 Replies)
Discussion started by: rainbow_bean
15 Replies

6. UNIX for Dummies Questions & Answers

Send a massive message to the connected users

How can I send a message for all the users connected into the system at the same time? Let's say I need to reboot the server and I ask the users to save their jobs becasue the server will be rebooted? (5 Replies)
Discussion started by: agasamapetilon
5 Replies

7. Shell Programming and Scripting

users login

Hello everyone I need to send to a file the last command from all users who log in and log out by week or month. My questions are I can do it with the command or I need to do a script ? If the answer is I need to do a script, someone can help me because Im complete new to make a... (3 Replies)
Discussion started by: lo-lp-kl
3 Replies

8. AIX

Change users login name

Hi, I need to change some users login name in AIX. With solaris i donīt had problems, i have used "usermod". But in AIX the usermod command donīt have the same behavior. Can someone give me a tip on how to perform these changes? Thanks in advance. (9 Replies)
Discussion started by: spacewalker
9 Replies

9. UNIX for Dummies Questions & Answers

Monitoring connected users

Hello every body Happy new year and merry christmass. Is there a way to monitor the users who are connecting to a Solaris 2.8 Sun Spark workstation . I just need to monitor the users and the command they are usning during telnet or rsh to my workstation. Cheers (2 Replies)
Discussion started by: Reza Nazarian
2 Replies
Login or Register to Ask a Question