What would be the easiest was to accomplish this?
Find all ports that do not have 'switchport port-security'
show run | exclude ?
I don't have a swicth with me and packet tracer does not have the commands avaliable.
Another option if you're willing to use a python script, use ciscoconfparse.find_parents_wo_child().
In your case, usage would be:
from ciscoconfparse import CiscoConfParse
parse = CiscoConfParse('/path/to/configuration/file')
missing = parse.find_parents_wo_child('^interface', 'switchport port-security$')
for intf in missing:
print(intf)
Save that script to a file and run it (after you install ciscoconfparse). That script will print interfaces without port-security.
This is the github link to the library: ciscoconfparse
Full disclosure: I am the author of the library
I can't see a way to make exclude work in this situation.
You could try something like the below which will show all the interfaces port-security lines (you would just need to find interfaces with none of those - i.e. where you have two interface lines in a row):
show run | include (^interface|port-security)
Or, if this is the specific case you are trying to achieve, a simple show port-security
will list all the ports that have port-security enabled.
include
command, you might put the result in a file. From there with vi
write a macro which will join any line prior one containing port-security
. Finally remove all the lines containing port-security
. The remaining lines are the ports without port-security
.
vi
?