1

I have a question on getting the most common names in the /etc/passwd file on Unix.

Is this the correct command?:

cut -d: -f5 /etc/passwd | uniq -c | sort -i | sort -n
Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
Ryan O
  • 11
  • 1

1 Answers1

0

You want to sort before you uniq, uniq only looks for adjacent unique lines, so if they aren't sorted first they likely won't be affected.

You might want something like:

cut -d: -f5 /etc/passwd | sort -i | uniq -c | sort -nk1,1
jesse_b
  • 35,934
  • 12
  • 91
  • 140