Linux Scroll

Just another WordPress.com site

Sort by UID, GID

How to sort by user uid , from /etc/passwd file.

$ sort -t: -k 3,4 -g /etc/passwd

-t = identifies the field separator colon (:)
-k 3,4 = determines the order in which fields will be compared for the sort.
3rd field (UID) followed by the 4th field (GID)
-g = sort to occur numerically

How to sort by group gid , from /etc/group file.

$ sort -t: -k 3 -g /etc/group

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: