Suppose I am having three input files as shown below:
File 1
1001 1 2 3
1002 4 5 6
1003 7 8 9
1004 10 11 12
File 2
1001 11 22 33
1002 44 55 66
1004 100 111 122
File 3
1001 111 222 333
1004 130 141 152
I would like to compare the first field of File3 with the first field of File 2. If a particular first field in File 2 doesn’t exist in File 3, then I want to delete that entire row in File 2.
For example, first field on Row 2 of File 2 (=1002) doesn’t exist in File 3. Hence I want to delete this row in File 2 and save it.
Now I want to compare File 3 and File 1. We see that the first field of second row (=1002) and the first field of the third row (=1003) of File 1 doesn’t exist in File 3.
I want to delete these two rows from File 1 and save it.
After the above steps, the three files would result as the following:
File 1
1001 1 2 3
1004 10 11 12
File 2
1001 11 22 33
1004 100 111 122
File 3
1001 111 222 333
1004 130 141 152