Hello,
I am attempting to combine two files where the second file can have more than one match with the lookup field (node) in the first file, onto one line of the output file. Also alerting if a lookup was not found in file2
=-=-=-=-=-=-=
Example of file1
node,type
=-=-=-=-=-=-=
bob,232
fred,202
jim,202
pat,232
sam,232
ted,118
tim,118
......
(up to around 15,000 lines)
=-=-=-=-=-=-=-=
Example of file2
node,serialnumber
=-=-=-=-=-=-=-=
alan,TEW9873FG
bob,XVT81283WS
fred,YHW81342BB
fred,YHW83281BA
fred,YHW98746CR
jake,QWE9896AQ
pat,LKJ55432GH
sam,QER8984UH
sam,QER6536WE
sam,QER2343ET
sid,ASW9093TW
ted,OPW4324TY
val,RWT6492OK
.....
(up to around 20,000 lines)
=-=-=-=-=-=-=-=-=
Output file required
=-=-=-=-=-=-=-=-=
bob,232,XVT81283WS
fred,202,YHW81342BB;YHW83281BA;YHW98746CR
jim,202,NO_SERIAL_FOUND
pat,232,LKJ55432GH
sam,232,QER8984UH;QER6536WE;QER2343ET
ted,118,OPW4324TY
tim,118,NO_SERIAL_FOUND
I have managed to combine lines using two read file loops in ksh but this will only give me a single line match between file1 file2. Also tried a
join -t',' which will give me results of nodes with more than one serial on a newline per serial (and sometimes not able find some of the matches at all)
Any advice how to tackle this would much appreciated,
Kind rgds,
John.