I have two files. File-A having 5 columns and File-B having 2 columns.
I want to match 4th column of file-A with both columns of file-B and print all contents of file-A + the matching lines of file-B as output.
The idea of matching fields in one file against a field in another file is easy with awk . But, given that there is only one line in file-B where both columns are the same and there is no line in file-A that contains the value that appears in that line in file-B, there is no output matching your request. Or, did I misunderstand what you're trying to do???
And, if there were lines in your input files that met your criteria, your description of the output you want is not clear.
Please describe more clearly what you are trying to do and show us the sample output you are trying to produce from your sample inputs.
---------- Post updated at 11:13 ---------- Previous update was at 11:06 ----------
Based on wild guesses, and appreciating what Don Cragun said (NO matches!), and having removed the DOS <CR> line terminators in file-A, this seemed to do sth like what you wanted:
Actually both the columns of file-B are interacting-protein-partners.
I want to match the column4 of file-A with both the columns of file-B, to see which of the protein of column4, file-A is also present in any of the column of file-B along with its corresponding protein partner.
i.e all columns of file-A + the matching LINE (both columns) of file-B (if either column contains a value same as that in column4 of file-A).
In the given output note that column2 of file-B had the same value as that of column4 file-A.
You description makes it sound like the text shown in red above in the output you say you want should appear in file-A (and it does appear as the 4th line in your sample) and the text shown in orange should appear in file-B (but it does not). There is no match in the 1st field nor in the 2nd field on any line in file-B for the 4th field on any line in file-A in your sample.
And, even if the text in orange did appear in file-B, there would still be no match... The 4th field in file-A:
DIP-46805N|uniprot:P70388
and the last field you have shown in your desired output:
Yep, that's a mistake on my part. They sure don't match exactly.
The contents of file-A and B that I have given in my question initially was just an example (and not a very good one) of a very large data set (forgot to mention that).
I sure would try to be more elaborate and exact next time.
Anyhow, the code RudiC has suggested works fine, just the way I wanted.