LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   example on the cut slide to display a list of users logged in. (https://www.linuxquestions.org/questions/linux-newbie-8/example-on-the-cut-slide-to-display-a-list-of-users-logged-in-923898/)

abhinav4 01-15-2012 10:12 AM

example on the cut slide to display a list of users logged in.
 
example on the cut slide to display a list of users logged in.

I know who will be used, but in the delimiter part dont know how to specify a space or a tab

Dick Dastardly 01-15-2012 10:21 AM

Specify a space like
Code:

echo "a b c"|cut -d" " -f2
Just put a tab in place of the space (cut -d" ") for tabs.

This should do the trick

Code:

who -u|cut -d" " -f1|uniq

devUnix 01-15-2012 10:45 AM

Code:

[demo@localhost ~]$ who | cut -d " " -f 1
demo
demo
[demo@localhost ~]$ who | cut -d " " -f 1 | uniq
demo


[demo@localhost ~]$ who | awk '{print $1}' | sort -u
demo
[demo@localhost ~]$


abhinav4 01-15-2012 11:05 PM

Thanks All


All times are GMT -5. The time now is 08:39 AM.