I want to join two files and index them in a new column as show below :
file A
apple 1 2 3 4 5 6
banana 3 2 4 4 5 6
orange 2 3 4 5 6 7
pear 2 4 5 6 3 5
file B
apple 1 3 4 5 6 7
grapes 4 5 6 4 3 6
melon 3 4 5 2 5 1
orange 2 4 5 6 7 8
I want to compare the two files based on first two columns, and output the common rows from file A and then add unique rows from both file A and file B and index them as shown below
output:
apple 1 2 3 4 5 6 both
orange 2 3 4 5 6 7 both
banana 3 2 4 4 5 6 fileA
pear 2 4 5 6 3 5 fileA
grapes 4 5 6 4 3 6 fileB
melon 3 4 5 2 5 1 fileB
commcompares two files and reports which lines occur in one, the other or both:As you can see, the pipeline is pretty complicated. If you plan to make changes to the code, consider moving to a more powerful language like Perl.