user5508084
user5508084

Reputation: 3

how to use sort, cut, and unique commands in pipe

I was wondering how do you use the cut, sort, and uniq commands in a pipeline and give a command line that indicates how many users are using each of the shells mentioned in /etc/passwd? i'm not sure if this is right but

cut -f1 -d':' /etc/passwd | sort -n | uniq 

?

Upvotes: 0

Views: 1143

Answers (1)

Armali
Armali

Reputation: 19375

Summarizing the answers excruciatingly hidden in comments:

You were close, only

  • as tripleee noticed, the shell is in the seventh field
  • as shellter noticed, since the shells are not numbers, -n is useless
  • as shellter noticed, for the counting, there's uniq -c

That gives

cut -f7 -d: /etc/passwd | sort | uniq -c

Upvotes: 1

Related Questions