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
  • 67,283
  • 35
  • 116
  • 255
Ryan O
  • 11

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
  • 37,005