Hi,
I need to compare the /etc/passwd files from 2 servers, and extract the users that are similar in these two files. I sorted the 2 files based on the user IDs (UID) (3rd column). I first sorted the files using the username (1st column), however when I use comm to compare the files there is no output listed.
This is the first file :
# cat sortvs1.csv
mastersam:0:MasterSAM user ID, 03072017
root:0:Super-User
daemon:1:
bin:2:
sys:3:
adm:4:Admin
uucp:5:uucp Admin
nuucp:9:uucp Admin
smmsp:25:SendMail Message Submission Program
listen:37:Network Admin
gdm:50:GDM Reserved UID
lp:71:Line Printer Admin
webservd:80:WebServer Reserved UID
postgres:90:PostgreSQL Reserved UID
svctag:95:Service Tag UID
unknown:96:Unknown Remote UID
fdsuser:1001:FDS system user
oracle:40098:
vs:40099:FTP user
Umvsftp:40100:FTP user
crmftp:40101:CRM ftp user
skmmftp:40103:SKMM ftp user
etiger:40104:
fouser:40107:
pmuser:40118:Preventive Maintenance Team
erohsik:40119:Rohan Sikka, Ericsson GNOC
IAN:40124:Ian Chew Yue Yen, umobile
emansab:40134:Manpreet Singh Sabharwal, Ericsson GNOC
ebfhiil:40136:Gaurav Mehra, Ericsson GNOC
nasha:40137:Nasha Baharom, UMobile Developer, 1072015
egi34597:40143:ANAND KUMAR, MO 2nd LA, 31052016
egi35624:40144:Rinki Saha, MO 2nd LA, 31052016
egi37391:40145:Richa Sharma, MO 2nd LA, 31052016
egi40026:40146:AMARNATH BHUNIA, MO 2nd LA, 31052016
eshisea:40147:Seah Shiao Yin, BSCS SME, 31052016
eqsvvvx:40148:Vishal Gupta, Ericsson DRP Project, 13062016
emoaigin:40158:Aigini Navaneethan, Ericsson Sysadmin, 25082016
weiping:40159:Wan Wei Ping, weiping.wan@u.com.my, 28112016
emoazizu:40162:
nobody:60001:NFS Anonymous Access User
noaccess:60002:No Access User
nobody4:65534:SunOS 4.x NFS Anonymous Access User
#
This is the 2nd file :
# cat sortvs2.csv
mastersam:0:MasterSAM User ID, 03072017
root:0:Super-User
daemon:1:
bin:2:
sys:3:
adm:4:Admin
uucp:5:uucp Admin
nuucp:9:uucp Admin
smmsp:25:SendMail Message Submission Program
listen:37:Network Admin
gdm:50:GDM Reserved UID
lp:71:Line Printer Admin
webservd:80:WebServer Reserved UID
postgres:90:PostgreSQL Reserved UID
svctag:95:Service Tag UID
unknown:96:Unknown Remote UID
fdsuser:1001:FDS system user
oracle:40098:
vs:40099:FTP user
Umvsftp:40100:FTP user
crmftp:40101:CRM ftp user
skmmftp:40102:SKMM ftp user
etiger:40103:
fouser:40107:
emorajen:40116:Rajendra Nagireddy, Ericsson GNOC
pmuser:40118:Preventive Maintenance Team
erohsik:40119:Rohan Sikka, Ericsson GNOC
IAN:40125:Ian Chew Yue Yen, umobile
emansab:40134:Manpreet Singh Sabharwal, Ericsson GNOC
ebfhiil:40136:Gaurav Mehra, Ericsson GNOC
nasha:40137:Nasha Baharom, UMobile Developer, 1072015
egi34597:40143:ANAND KUMAR, MO 2nd LA, 31052016
egi35624:40144:Rinki Saha, MO 2nd LA, 31052016
egi37391:40145:Richa Sharma, MO 2nd LA, 31052016
egi40026:40146:AMARNATH BHUNIA, MO 2nd LA, 31052016
eshisea:40147:Seah Shiao Yin, BSCS SME, 31052016
eqsvvvx:40148:Vishal Gupta, Ericsson DRP Project, 13062016
weiping:40158:Wan Wei Ping, weiping.wan@u.com.my, 28112016
emoaigin:40161:
emoazizu:40162:
nobody:60001:NFS Anonymous Access User
noaccess:60002:No Access User
nobody4:65534:SunOS 4.x NFS Anonymous Access User
#
This is the output after comparing both the files (I used comm) :
# comm -12 sortvs1.csv sortvs2.csv
root:0:Super-User
daemon:1:
bin:2:
sys:3:
adm:4:Admin
uucp:5:uucp Admin
nuucp:9:uucp Admin
smmsp:25:SendMail Message Submission Program
listen:37:Network Admin
gdm:50:GDM Reserved UID
lp:71:Line Printer Admin
webservd:80:WebServer Reserved UID
postgres:90:PostgreSQL Reserved UID
svctag:95:Service Tag UID
unknown:96:Unknown Remote UID
fdsuser:1001:FDS system user
oracle:40098:
vs:40099:FTP user
Umvsftp:40100:FTP user
crmftp:40101:CRM ftp user
#
As you can see from the compared output, the list only lists users till the user ID 40101. But if you see the first two files, there are other IDs in it, like 40162. Why does it not list this ID?
Also is it not possible to get the similar names if I sort both the files using username (first column)? Is there any other way to do so? This is because there are some usernames with different UIDs in each server.
Another question is, how (which command to use) to list similar user IDs in multiple files (10 - 15).