cut -d ':' -f 1,3 /etc/passwd | sort -t ':' -k2n - | tr ':' '\t'
The cut
command extracts fields from each line in the password file:
-d ':'
means to use :
as the field separator-f 1,3
means to extract the 1st and 3rd fields. These correspond to username and user id, respectivelyThe sort
command sorts lines:
-t ':'
means to use :
as the field separator-k2n
means to sort by the second field, in numeric orderFinally, the tr
command replaces all occurrences of :
with a tab character.