I have this requirement where show mac address table
of a switch will list 1000 entries .
file1: switch_1#show mac address table AA:AA:AA:AA:AA:AA port 47 BB:BB:BB:BB:BB:BB port 48 . . . DD:DD:DD:DD:DD:DD port 50
file2: switch_2#show mac address table AA:AA:AA:AA:AA:AA port 47 BB:BB:BB:BB:BB:BB port 48 . . . DD:DD:DD:DD:DD:DD port 45
I need to find a way to display the line containing DD:DD:DD:DD:DD:DD
and once this occurs, it should search few lines above and print the hostname containing line as well
So the output should look like:
switch_1#show mac address table DD:DD:DD:DD:DD:DD port 50 switch_2#show mac address table DD:DD:DD:DD:DD:DD port 45
file1
, file2
are stored in the same directory
(these are just examples, there is like 100+ files/switches and MAC needs to be filtered along with the switch names)