Compare every line of one file with every line of another file
I have two files:
file1
cat file1
A,1
B,2
C,2
D,3
file2
cat file2
A
A
A
B
B
C
C
D
Desired output
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 file1
must be matched against each line file2
, and if they match, then the line from file1
must be appended to the corresponding line in file2
. I tried join
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.
thank
+3
source to share