Show Command Multiple Filtering

Normally when we do show command we make use of the "|" to filter and put in keywords after like include, exclude, begin and section. As we all know "include" means show only that matches the string like for the example below.


R1#sh run | inc CISCO
neighbor CISCO peer-group

We can do some multiple command filtering like the example below using the "include" keyword. Let's say we want to see the interface name, then the description, the OSPF cost and if its configured with the "mpls ip" command.


R1#sh run | inc interface |^ description |^ ip ospf cost |^ mpls ip
interface FastEthernet0/0
description towards LAN
ip ospf cost 100
mpls ip

The trick is to use multiple "|" and then the regular expression "^". Then put a space before the string because the configurations under the interface configuration if you do a "show run" has a space before the line. This also applies to the "exclude" keyword but who the heck uses "exclude" that much? There goes another stupid blog entry post. :)

Comments

2 Responses to "Show Command Multiple Filtering"

Anonymous said... August 5, 2010 at 2:45 PM

Hi,

I noticed you can accomplish the same thing by doing:
#sh run | inc (int|desc|ip)

It's simpler and easier to remember.

Dennis O.

Anonymous said... January 17, 2011 at 12:37 AM

It's not the same because your regular expression example (x|y|z..) will match also things like:

hostname
multilink bundle-name authenticated
username

Post a Comment

Certifications

Certifications

The Dreamer

A fun loving person who enjoys learning new things. Currently working as a Network Engineer supporting the global network of a Fortune 500 company. This blog serves as my notes for the labs I created for my CCIE journey. I can guarantee there are errors in my posts. If you spot them, please let me know.

Join my Facebook Page I WANT TO BE A CCIE

Donate to the Cause

My aim is to create materials for free and possibly a free lab. If you wish to help out, please send any amount. Thanks.

Join my Bandwagon

Blogs that I Read