Remove multiple lines that match pattern

Not sure how I can accomplish this. I would like to remove all interfaces that have the commands I would like to see: switchport port-security, spanning-tree portfast. One line is no problem.

interface FastEthernet0/8
 spanning-tree portfast 
interface FastEthernet0/9
 spanning-tree portfast
interface FastEthernet0/10 
 spanning-tree portfast
interface FastEthernet0/11
 switchport port-security
 spanning-tree portfast
interface FastEthernet0/12

I would like the results to be

interface FastEthernet0/8
 spanning-tree portfast 
interface FastEthernet0/9
 spanning-tree portfast
interface FastEthernet0/10 
 spanning-tree portfast
interface FastEthernet0/12

Thanks

Not clear. Do you want to remove those interfaces that have both commands trailing?

Yes, correct.

Try

awk     'function PRTOUT()      {if (SW&&ST) return;
                                 print IN; if (SW) print SW; if (ST) print ST};
         /interface/            {if (NR > 1) PRTOUT();  SW=ST=""; IN=$0}
         /switchport/           {SW=$0}
         /spanning-tree/        {ST=$0}
         END                    {PRTOUT()}
        ' file
interface FastEthernet0/8
 spanning-tree portfast 
interface FastEthernet0/9
 spanning-tree portfast
interface FastEthernet0/10 
 spanning-tree portfast
interface FastEthernet0/12

Try:

awk '/interface/{print x}1' file | awk '!(/switchport port-security/ && /spanning-tree portfast/)' RS=
interface FastEthernet0/8
 spanning-tree portfast 
interface FastEthernet0/9
 spanning-tree portfast
interface FastEthernet0/10 
 spanning-tree portfast
interface FastEthernet0/12
1 Like