I am new to the use of the bash shell and all the unix commands. So I hope my question is not too stupid, I could not find anything in the previously asked questions to help me solving my problem.
I created a file that looks like this:
apple:::NN \t garden:::NN \t 5 garden:::NN \t great:::Adj \t 1 nice:::Adj \t a:::DT \t 2 etc
Now I have another file:
apple:::NN \t garden:::NN \t 15 house:::NN \t nice:::Adj \t 1 garden:::NN \t great:::Adj \t 5 etc
I need to combine the files, so the merged output file would look like this:
apple:::NN \t garden:::NN \t 20 garden:::NN \t great:::Adj \t 6 nice:::Adj \t a:::DT \t 2 house:::NN \t nice:::Adj \t 1
The problem is that the lines are not the same in both files, so I cannot iterate through the files line by line. I can split the lines of course, however I have to consider column 1 and column 2 as a unit to be able to add the numbers if column 1 and column 2 are the same in both files. Lines that are just found in 1 file have to go to the output file as they are.
I can do it manually using 'awk' or 'grep' but is it possible to also do that in a loop? If someone has a hint to solve the 'line' problem, that would help me a lot already!
The closest solution I could get to, is the following Merge files using a common column However, I could not get the join command using 2 columns plus adding up the values of the 3rd column.
I really appreciate any help!