Help! SHELL or AWK script - only the masters of the forum will solve
Hello everybody!
I have no experience with shell Programmer, but I need to compare 02 files. Txt and generate an output or a new file, after the comparisons. see:
If the column 1 of file1 is equal to column 1 of file2, and column 3 of file2 contains the column 4 of file1, output: column1 (file1); column2 (file1); col3 (file2); col3 (file1)
file1:
ARC-RJ-E320-01, 2009-11-26, GigabitEthernet, 0 / 0
ARC-RJ-E320-01, 2009-11-26, GigabitEthernet, 1 / 0
ARC-RJ-E320-01, 2009-11-26, GigabitEthernet, 3 / 0
ARC-RJ-E320-01, 2009-11-26, GigabitEthernet, 5 / 0
ARC-RJ-E320-01, 2009-11-26, ATM, 13 / 0
ARC-RJ-E320-01, 2009-11-26, ATM, 14 / 0
ARC-RJ-E320-01, 2009-11-26, ATM, 15 / 0
BOT-RJ-E320-03, 2009-11-26, GigabitEthernet, 0 / 0
BOT-RJ-E320-03, 2009-11-26, GigabitEthernet, 1 / 0
BOT-RJ-E320-03, 2009-11-26, GigabitEthernet, 3 / 0
BOT-RJ-E320-03, 2009-11-26, GigabitEthernet, 5 / 0
BOT-RJ-E320-03, 2009-11-26, GigabitEthernet, 14 / 0
BOT-RJ-E320-03, 2009-11-26, GigabitEthernet, 15 / 0
BRB-RJ-E320-02, 2009-11-26, GigabitEthernet, 0 / 0
BRB-RJ-E320-02, 2009-11-26, GigabitEthernet, 1 / 0
BRB-RJ-E320-02, 2009-11-26, GigabitEthernet, 3 / 0
BRB-RJ-E320-02, 2009-11-26, GigabitEthernet, 5 / 0
BRB-RJ-E320-02, 2009-11-26, GigabitEthernet, 14 / 0
MAR-RJ-E320-01, 2009-11-26, GigabitEthernet, 0 / 0
MAR-RJ-E320-01, 2009-11-26, GigabitEthernet, 1 / 0
MAR-RJ-E320-01, 2009-11-26, GigabitEthernet, 3 / 0
MAR-RJ-E320-01, 2009-11-26, GigabitEthernet, 5 / 0
MAR-RJ-E320-01, 2009-11-26, GigabitEthernet, 14 / 0
MAR-RJ-E320-01, 2009-11-26, GigabitEthernet, 15 / 0
file2:
ARC-RJ-E320-01, 2009-11-26, 0/0/0, 9278
ARC-RJ-E320-01, 2009-11-26, 1/0/0, 6949
ARC-RJ-E320-01, 2009-11-26, 3/0/0, 5345
ARC-RJ-E320-01, 2009-11-26, 5/0/1, 8842
ARC-RJ-E320-01, 2009-11-26, 11/0/0; 2316
ARC-RJ-E320-01, 2009-11-26, 11/0/1; 3392
ARC-RJ-E320-01, 2009-11-26, 13/0/0; 1300
ARC-RJ-E320-01, 2009-11-26, 13/0/1; 1752
ARC-RJ-E320-01, 2009-11-26, 13/0/2; 1188
ARC-RJ-E320-01, 2009-11-26, 13/0/3, 900
ARC-RJ-E320-01, 2009-11-26, 14/0/0; 728
ARC-RJ-E320-01, 2009-11-26, 14/0/1; 230
ARC-RJ-E320-01, 2009-11-26, 14/0/2; 1147
ARC-RJ-E320-01, 2009-11-26, 14/0/3; 1053
ARC-RJ-E320-01, 2009-11-26, 15/0/0; 1110
ARC-RJ-E320-01, 2009-11-26, 15/0/1, 129
ARC-RJ-E320-01, 2009-11-26, 15/0/2; 1204
ARC-RJ-E320-01, 2009-11-26, 15/0/3; 456
BOT-RJ-E320-03, 2009-11-26, 0/0/0, 2745
BOT-RJ-E320-03, 2009-11-26, 1/0/0, 220
BOT-RJ-E320-03, 2009-11-26, 3/0/0; 10,021
BOT-RJ-E320-03, 2009-11-26, 5/0/0, 5815
BRB-RJ-E320-02, 2009-11-26, 0/0/0, 7118
BRB-RJ-E320-02, 2009-11-26, 1/0/0, 1891
BRB-RJ-E320-02, 2009-11-26, 3/0/0, 5401
BRB-RJ-E320-02, 2009-11-26, 5/0/0, 6606
MAR-RJ-E320-01, 2009-11-26, 0/0/0, 2777
MAR-RJ-E320-01, 2009-11-26, 3/0/0, 3697
MAR-RJ-E320-01, 2009-11-26, 5/0/0, 2952
or has to be generated output:
column1 (file1); column2 (file1); col3 (file2); col3 (file1)
ARC-RJ-E320-01, 2009-11-26, 0/0/0; GigabitEthernet
ARC-RJ-E320-01, 2009-11-26, 1/0/0; GigabitEthernet
ARC-RJ-E320-01, 2009-11-26, 3/0/0; GigabitEthernet
ARC-RJ-E320-01, 2009-11-26, 5/0/1; GigabitEthernet
ARC-RJ-E320-01, 2009-11-26, 13/0/0; ATM
ARC-RJ-E320-01, 2009-11-26, 13/0/1; ATM
ARC-RJ-E320-01, 2009-11-26, 13/0/2; ATM
ARC-RJ-E320-01, 2009-11-26, 13/0/3; ATM
ARC-RJ-E320-01, 2009-11-26, 14/0/0; ATM
ARC-RJ-E320-01, 2009-11-26, 14/0/1; ATM
ARC-RJ-E320-01, 2009-11-26, 14/0/2; ATM
ARC-RJ-E320-01, 2009-11-26, 14/0/3; ATM
ARC-RJ-E320-01, 2009-11-26, 15/0/0; ATM
ARC-RJ-E320-01, 2009-11-26, 15/0/1; ATM
ARC-RJ-E320-01, 2009-11-26, 15/0/2; ATM
ARC-RJ-E320-01, 2009-11-26, 15/0/3; ATM
BOT-RJ-E320-03, 2009-11-26, 0/0/0; GigabitEthernet
BOT-RJ-E320-03, 2009-11-26, 1/0/0; GigabitEthernet
BOT-RJ-E320-03, 2009-11-26, 3/0/0; GigabitEthernet
BOT-RJ-E320-03, 2009-11-26, 5/0/0; GigabitEthernet
BRB-RJ-E320-02, 2009-11-26, 0/0/0; GigabitEthernet
BRB-RJ-E320-02, 2009-11-26, 1/0/0; GigabitEthernet
BRB-RJ-E320-02, 2009-11-26, 3/0/0; GigabitEthernet
BRB-RJ-E320-02, 2009-11-26, 5/0/0; GigabitEthernet
MAR-RJ-E320-01, 2009-11-26, 0/0/0; GigabitEthernet
MAR-RJ-E320-01, 2009-11-26, 3/0/0; GigabitEthernet
MAR-RJ-E320-01, 2009-11-26, 5/0/0; GigabitEthernet
thanks.
He2