Hi,
I need shell script to compare the two files based on certain fields and output should contains the required fields based on result.pls find sample input files and required output
file 1
HTML Code:
COUNT, BNG_IP,PORT,OVLAN
22 , 10.238.60.129,1/1,2009
144 , 10.238.60.129,1/1,2251
3 , 10.238.60.129,1/1,2255
48 , 10.238.60.129,1/1,2294
32 , 10.238.60.129,1/1,2677
137 , 10.238.60.129,1/1,2682
49 , 10.238.60.129,1/1,2683
17 , 10.238.60.129,1/1,2684
123 , 10.238.60.129,1/1,2686
74 , 10.238.60.129,1/1,2731
8 , 10.238.60.129,1/1,2896
39 , 10.238.60.129,2/1,2002
8 , 10.238.60.129,2/1,2310
9 , 10.238.60.129,2/1,2312
4 , 10.238.60.129,2/1,2313
13 , 10.238.60.129,2/1,2314
1 , 10.238.60.129,2/1,2316
File 2
HTML Code:
BNG_IP DSLAM_IP PORT
10.238.60.129 , 10.232.0.9 , 1/1 , 2009:124
10.238.60.129 , 10.232.2.2 , 2/1 , 2302:122
10.238.60.129 , 10.232.2.3 , 2/1 , 2303:122
10.238.60.129 , 10.232.2.4 , 2/1 , 2304:122
10.238.60.129 , 10.232.2.6 , 2/1 , 2306:122
10.238.60.129 , 10.232.2.7 , 2/1 , 2307:122
10.238.60.129 , 10.232.2.8 , 2/1 , 2308:122
10.238.60.129 , 10.232.2.9 , 2/1 , 2309:122
10.238.60.129 , 10.232.2.10 , 2/1 , 2310:122
10.238.60.129 , 10.232.2.11 , 2/1 , 2311:122
10.238.60.129 , 10.232.2.12 , 2/1 , 2312:122
10.238.60.129 , 10.232.2.13 , 2/1 , 2313:122
10.238.60.129 , 10.232.2.16 , 2/1 , 2316:122
10.238.60.129 , 10.232.2.17 , 2/1 , 2317:122
10.238.60.129 , 10.232.2.18 , 2/1 , 2318:122
Script should compare the first file with second file for BNG_IP,PORT,OVLAN fields if its available in file 2 .it should give the corresponding DSLAM_IP from file2
Required out put will be as below
Output
HTML Code:
COUNT, BNG_IP,PORT,OVLAN,DSLAM_IP
22 , 10.238.60.129,1/1,2009 ,10.232.0.9
8 , 10.238.60.129,2/1,2310,10.232.2.10
9 , 10.238.60.129,2/1,2312,10.232.2.12
4 , 10.238.60.129,2/1,2313,10.232.2.13
1 , 10.238.60.129,2/1,2316,10.232.2.16