18

With help of the who command we can get active users, I want only the first field such as

user 1
user 2
user 3
kiri
  • 28,246
  • 16
  • 81
  • 118
ArUn
  • 357
  • 1
  • 5
  • 13

1 Answers1

27

You can get just the user names like so:

who | awk '{print $1}' | sort 

Where who lists all logged in users, passes the output to awk which only prints the first section ("column") of text for every line, passes it to sort which sorts the output.

Stabledog
  • 981