Hello,
Similar question to my previous posts. I am sorry for the trouble...
Just checked my old threads but I can not implement any solution into this case..
My aim is to grab each line in fileA, check it in fileB and merge with fileC (tab separated) in corresponding line as given below:
FileA: just nba teams,
FileB: nba teams with a couple of team players (team-player-team-player-team-player)
FileC: my current file
Output: merged output
FileA:
Golden State Warriors
Boston Celtics
New York Knicks
Toronto Raptors
Chicago Bulls
FileB:
Golden State Warriors
Andrew_Bogut
Golden State Warriors
Quinn_Cook
Boston Celtics
PJ_Dozier
Boston Celtics
Jonathan_Gibson
New York Knicks
Mario_Hezonja
New York Knicks
Isaiah_Hicks
New York Knicks
John_Jenkins
FileC:
Golden State Warriors Jordan_Bell
Boston_Celtics Jaylen_Brown
New York Knicks Henry_Ellenson
Toronto_Raptors OG_Anunoby
Chicago Bulls Raw_Alkins
Output:
Golden State Warriors Jordan_Bell Andrew_Bogut Quinn_Cook
Boston Celtics Jaylen_Brown PJ_Dozier Jonathan_Gibson
New York Knicks Henry_Ellenson Mario_Hezonja Isaiah_Hicks John_Jenkins
Toronto_Raptors OG_Anunoby
Chicago Bulls Raw_Alkins
Multiple loops
caused intensive headache here..
I'd appreciate your help..
Edit: I am near to solution with awk.. Working on it...
I think that Vgersh's old post will do that...
awk -f test.awk FileA FileB FileC
test.awk
FNR==NR { a[$1];next}
$1 in a {a[$1]=a[$1] OFS $2}
END {
for (i in a)
print i,a
}
Solved: Even though file format is a bit different, it works with some extra manipulation.
Thank you
Boris