Sorting Your Users By Logging Shell They Use
If you wanted to sort the users in your system by the login shell they use, you could use this command: sort -t: +6 /etc/passwd
This is how it works, the option -t: tells sort to use a colon as a field separator — so, in this example, field 0 is the login name, field 1 is the encoded password, field 2 is the user ID number, field 3 is the group ID number, and so on. By this numbering, the login shell is in the sixth field.
As you can see in this example passwd file is sorted by the login shell they use.
By same method if we want to sort by UID we would use sort -t: +2 /etc/passwd
… or in alphabetical order: sort -t: +0 /etc/passwd



