Bash join script not working

So i'm currently working on a project where I'm attempting to display information of users from the /etc/passwd file and also another information file holding addition information about users.

Problem is I've been trying to join the two files together and have all of the information about each user in 1 file on 1 line for each user but it doesn't want to work for me.
Both files are delimited by colons.

note: information here is made-up .

$cat AdditionalInfo
 Usr1:Jill Smith:123 Sunset Avenue:1990:2001
 Usr2:Jack Bloggs:321 Sunrise Street:1989:2010
 ect....

/etc/passwd has lots more users than the few that are in the Additional information file and i only need the info from /etc/passwd for those records.

So far all my attempts of joining the files end with either no output, or only the output from the additionalinfo file.

$join -t: AdditionalInfo /etc/passwd

gives nothing.

if anyone knows why this doesn't work and can offer a solution it would be greatly appreciated.

Desired output would be

Usr1:Jill@mail.com:123 Sunset Avenue:1990:2001:x:1000:1000:Jill Smith:/home/admin/Usr1:/bin/bash
Usr2:Jack@mail.com:321 Sunrise Street:1989:2010:x:1001:1001:Jack Bloggs:/home/admin/Usr2:/bin/bash
-

join works with sorted files.
therefore, both must be sorted prior to the 'join' command.

you may sort to new filenames prior to the 'join', or try to sort in-line
i would recommend sorting to new filenames first.

1 Like

Update:

$sort -t: -k1 AdditionalInfo > AdditionalInfo.srt
$sort -t: -k1 /etc/passwd > etcpasswd.srt
$join -t: AdditionalInfo.srt etcpasswd.srt

Joins the matching fields correctly thanks.
Literally figured it out as you were posting :stuck_out_tongue: