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
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
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