Often our router and switch configs will end up being many pages long.  When you need to check that config for a specific line or setting, you’ll often end up pounding the spacebar to scroll through several pages.  The easier way to find what you’re looking for is to search using the pipe (|) command.

Here is an example of the pipe.  This command will search through the running config for anything containing

sh run | include snmp-server community

and the output is:

snmp-server community MySecureSnmpString RO

 

 

To break things down a bit, the include directive (AKA pipe) tells the IOS to only display items that meet specific criteria.  You’ll want to show (sh) a particular set of data (in this case the running config), then use the pipe key (|) and tell it what to include (or exclude)

show running-config | include

or, if you want to reduce your typing:

sh run | i

 

 

Other search options.  You can use pipe to search other things than the running configuration.  Here are some examples:

Routes:

sh ip route | i 10.94

Mac addresses:

show mac address-table | include ab36

Show all cdp neighbors and display their IP and Mac addresses:

show cdp neighbors detail | inc Dev|ress:

Display an entire section of the config:

sh run | section eigrp

Show all down interfaces:

show ip interface brief | include down

Or, show all interfaces that aren’t up:

show ip interface brief | exclude up

 

Search the Cisco IOS using pipe
Tagged on:                 

Leave a Reply