I have file 1 & file 2 with content mentioned below. I want to get the output as shown in file3.
Requirement:
check the content of column 1 & column 2, if value of column 1 in file1 matches with first column of file2 then remaining columns(2&3) of file2 should get replaced, also if value of column 2 in file1 matches with first column of file2 then remaining columns(2&3) of file2 should get replaced with comma separater.
i am not sure how to use awk for matching col1/col2 from file1 simultaneously & then replace the same with value of the same from file2 I am able to print using but parsing the complete file is an issue & then matching/replacing with file2 is not happening. NO IDEA HOW IT WILL HAPPEN & TOTALLY CONFUSED.
Please help
Your solution would need to be processing two files, you could do that using awk . There are many examples like that with the NR==FNR construct. You could first build an index (say using an array "A") with the entries from file 2 (column1 is the index, column 2 the value). Then when processing file 1 you can first look at field 2 and then at field 3 and if they are present in array "A" then replace them with that vaiue ( $2=A[$2] ). OFS can be used to change the output field separator to a comma.