Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to get a list of the currently logged users and their respective IP addresses.
I tried the following command line:

w -s

However, the TTY, IDLE and WHAT columns are also displayed. I don't want those columns to be displayed as I plan to use only the needed information as an input to a script. Is there any way to filter those columns out? Any way of getting a list with just the users and their IPs?

share|improve this question
up vote 3 down vote accepted

Does this work for you?

w -hs|awk '{printf "%s\t%s\n",$1,$3}'
share|improve this answer
It does. Thank you very much! Wow, it seems that I definitely need to learn more about awk. I feel so embarrassed :P – PALEN Apr 8 '13 at 3:50
It's a pretty handy tool for minor data processing tasks, I highly recommend adding it to your repertoire. – tink Apr 8 '13 at 4:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.