Operating System - Linux
1826290 Members
4610 Online
109692 Solutions
New Discussion

Re: how to get the duplicate GID

 
SOLVED
Go to solution
Soujanya
Valued Contributor

how to get the duplicate GID

How to write an awk program that reads /etc/passwd and prints the names of those users having the same GID in the form GID name1 name2 ......

Does the input data need to be sorted?


Any Help is much appreciated :)

Thanks in Advance
Soujanya.R
4 REPLIES 4
Manuel Wolfshant
Trusted Contributor

Re: how to get the duplicate GID

The information is already available in /etc/group, no need to parse /etc/passwd.
Manuel Wolfshant
Trusted Contributor

Re: how to get the duplicate GID

Oh, well, I stand corrected. Only for supplementary groups does /etc/group include the usernames. Primary group must be retrieved from /etc/passwd.
Atul Gautam
Valued Contributor

Re: how to get the duplicate GID

Hey Soujanya,

The command given below can give you a listing of the usernames and their GIDs but it will also contain the list of system users as well.

# awk -F: '{print $1 " " $4}' /etc/passwd





Atul
Atul Gautam
Valued Contributor
Solution

Re: how to get the duplicate GID

Also,

With proper formatting, the output can be generated using the command ---

awk -F: '{print NR ". " $4 " "$1}' /etc/passwd





Atul