I have a two part awk problem:
In the first part: I want to compare the second columns from two files. If there is a match, print the corresponding value in an output file.
In the second part: I also need the opposite information. Again, I want to compare the second columns from the same two files. If there is a unique string value (meaning something that appears in Column 2 in file 1 and not in Column 2 in file 2).
To solve the first part: I have used the following awk
awk 'NR==FNR { a[$1]=$2; next} $1 in a {print $0, a[$1]}' File2 File1
found here, which seems to solve the issue of identifying the matching values.
However, I cannot seem to find a solution to identifying the unique information from file 1 and printing it in a third output file. Can anyone provide any insight on how to solve this?
An example of the input is the following:
File 1
A concept1 123
A concept2 123
A concept1 123
A concept1 123
A concept3 123
File 2
B concept1 456
B concept4 456
B concept5 456
B concept1 456
B concept3 456
OUTPUT File 3
concept4
concept5
Thank you.
UPDATE: In the original, I have asked the question comparing 1 file against one other file. Is it possible to modify this code to compare 1 file against multiple other files?
For instance:
Input: FILE1 to be compared for any unique line against FILE2,FILE3,FILE4...FILEn OUTPUT: FILE with all unique lines from FILE1.