Display text is string matches below.

I have not idea how I would accomplish this. I have a script that scans for CDP neighbours. I get the results in a file. I am interested in CDP Neighbor Details if name BSWITCH shows up. If BSWITCH is not present then skip.

 
 CDP Neighbor Details for 10.200.21.1
--------------------------------------------------------------------------------------------
Neighbor IP                 Name                   Interface                   Type        |
--------------------------------------------------------------------------------------------
10.202.255.142    Bed                       inpath0_0              250
10.200.21.180     BSWITCH      GigabitEthernet0/1     cisco WS-C2960-8TC-L
10.200.21.241     BSWITCH1      GigabitEthernet0/1     cisco WS-C2960-48TT-L
10.201.242.1      core              Tunnel20               cisco ASR1004

 

I would like the results to read.

 
 CDP Neighbor Details for 10.200.21.1
--------------------------------------------------------------------------------------------
Neighbor IP                 Name                   Interface                   Type        |
--------------------------------------------------------------------------------------------
10.200.21.180     BSWITCH      GigabitEthernet0/1     cisco WS-C2960-8TC-L
10.200.21.241     BSWITCH1      GigabitEthernet0/1     cisco WS-C2960-48TT-L
 

It depends how you want to filter, including what you want or excluding what you don't want.

The simplest might be to use grep -Ev with an expression matching the records you want to exclude.

If you are not bothered about the titles in the report, it would be easier to use grep BSWITCH in your code.

What have you got so far that we can help with?

Robin