Unique Result

Good day folks,

I am trying to get the logged in users with the 'users' command, but I am having difficulty in making the name of users to appear only ONCE even if they are currenly logged in more than one terminal.

I could not use uniq becuase that only work with lines, but the users command does not print the result in lines.

many thanks in advance

One method:

 users | tr ' ' '\n' | sort | uniq

@ jacob

just t say thanks for that, it did work well.

can i just ask if any one can show me how to get the real name of logged in user from the finger command.

when I ran the following command:

finger userLogingName

i got the resul in the following format

Login: xxxxxx Name: yyy xxx
Directory:/home/xxxxxx shell: /bin/bash
on since wednesday 30......
No mail
No plan

but my issue is how to i GET only the name from this output, many thanks

Try:

finger <user_name>  | sed -n '/Login:/p' | sed 's/\(.*\)Name:\(.*\)/\2/'

is possible to archieve that without the sed command?

finger <<user>> | awk '/Login:/{print $NF}'

Let me apologise for being a pain jacob, but i trying not to use sophisticated command like sed or awk, to accomplish the task