Compare every line of one file with every line of another file
I have two files:
cat file1 A,1 B,2 C,2 D,3
cat file2 A A A B B C C D
cat output A,A,1 A,A,1 A,A,1 B,B,2 B,B,2 C,C,2 C,C,2 D,D,3
As you can see, each line
must be matched against each line
, and if they match, then the line from
must be appended to the corresponding line in
. I tried
it but it doesn't work. My guess is that the search should be recursive, but I'm not sure how to do this when there are two files involved.
Any help would be greatly appreciated.
source to share