Back in the days before stacks and VSS, doing a “show run” to look at something was easy. You pressed space a few times to page through the output and found the section you were interested in. Now when you’ve got a stack of several switches or switch running VSS with hundreds of interfaces you’ll be pressing space forever and a day paging through the config.
In IOS you can pipe output to a selection of commands to filter output. Much like redirecting output using a pipe in UNIX or even Powershell.
Switch#sh run | ? append Append redirected output to URL (URLs supporting append operation only) begin Begin with the line that matches exclude Exclude lines that match include Include lines that match redirect Redirect output to URL section Filter a section of output tee Copy output to URL
Say for example you want to see the static routes in the running-config:
Switch#sh run | inc ^ip route ip route 0.0.0.0 0.0.0.0 188.8.131.52
As with the above, regular expressions are acceptable too!
This is all well and good for commands such as “ip route” or “ntp” for example but what if you want to check an EIGRP config?
Switch#sh run | inc ^router router eigrp 10
Oh. This isn’t what we were expecting. This is because the EIGRP config is a section. Thankfully you can pipe to the “section” command:
Switch#sh run | section eigrp router eigrp 10 redistribute static passive-interface default no passive-interface FastEthernet1/0 no passive-interface FastEthernet1/1 network 10.0.0.0 network 192.168.1.0 0.0.0.3 network 192.168.1.4 0.0.0.3 no auto-summary
Much easier than “sh run” and then paging through the output until you find what you’re after.
And finally, if you’re in configuration mode and want to check something with show, ping etc and don’t want to have to drop back to priv exec mode, prefix your command with “do”:
Switch#conf t Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#int f1/1 Switch(config-if)#do sh run | section eigrp router eigrp 10 redistribute static passive-interface default no passive-interface FastEthernet1/0 no passive-interface FastEthernet1/1 network 10.0.0.0 network 192.168.1.0 0.0.0.3 network 192.168.1.4 0.0.0.3 no auto-summary Switch(config-if)#