Print unique of who command

awksortwho

I want to show the online users using the who command but I want to have a unique output and not show any duplicates. I piped the output into awk but I am not very familiar with that, is this the right way and how to proceed?

Best Answer

It's easier to just do it with sort:

 who | sort -u -k1,1

The -u flag asks for "unique" lines (suppress duplicates). The key flag (-k) says to only consider the first word in each line for purposes of sorting and uniqueness.

Related Question