What is the alternate command for "w" in linux?

The w command gives the user and the below details:

USER     TTY        FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
USER A abc/0    XX.XXX.XX.XX     14:32   41:10   0.10s  0.10s -bash
USER B abc/1    XX.XXX.XX.XX     13:42    2:46   0.10s  0.03s    ssh XX.XXX.XX.XX 

We try to extract all the data individually like the below but output is not having fixed length data. So looking for alternate command for “w”:

str1[0,0]= USER
str1[0,1]= TTY
str1[1,0]= USER A
str1[1,1]= USER B

Please tell us if we have alternate commands in unix/linux to get the same details as w(list of users and what each user is doing…) .

There is no altertive to w command as it display who is logged on and what they are doing. You can use awk to print each field.

# prints user name 
w | awk '{ print $1  }'
# prints tty
w | awk '{ print $2  }'