PDA

View Full Version : Show run | inc regular expression



3amigos
12-27-2009, 09:05 PM
Hi I was wondering if anyone had any useful examples of using regular expression in the show run | command?

Thanks

mosssec
12-27-2009, 09:06 PM
For sh run there is not much point in using regular expressions in the lab, as your config will be pretty small compared to that of a live network. You could do a sh run or a wr t and then use / to take you to a particular part. Like wr t <enter> and then /line to take you to the line con 0 without having to sift through pages to get there as it's always at the bottom.

Also, for a switch, especially one that has line cards, there are some awesome things you can do with REGEX, like:-

Show me all the ports, but GREP to Blade 1/40 through to 49.


Switch#sh ip int brief | i 1/4[0-9]!GigabitEthernet1/40 unassigned YES unset up upGigabitEthernet1/41 unassigned YES unset up upGigabitEthernet1/42 unassigned YES unset down downGigabitEthernet1/43 unassigned YES unset up upGigabitEthernet1/44 unassigned YES unset up upGigabitEthernet1/45 unassigned YES unset down downGigabitEthernet1/46 unassigned YES unset up upGigabitEthernet1/47 unassigned YES unset up upGigabitEthernet1/48 unassigned YES unset up up
!
!
Show me all the ports, but GREP to Blade 1/40 through to 49. and Blade 2.
!

Switch#sh ip int brief | i (1/4[0-9])|(2/1[0-9])!GigabitEthernet1/40 unassigned YES unset up upGigabitEthernet1/41 unassigned YES unset up upGigabitEthernet1/42 unassigned YES unset down downGigabitEthernet1/43 unassigned YES unset up upGigabitEthernet1/44 unassigned YES unset up upGigabitEthernet1/45 unassigned YES unset down downGigabitEthernet1/46 unassigned YES unset up upGigabitEthernet1/47 unassigned YES unset up upGigabitEthernet1/48 unassigned YES unset up upGigabitEthernet2/10 unassigned YES unset up upGigabitEthernet2/11 unassigned YES unset up upGigabitEthernet2/12 unassigned YES unset up upGigabitEthernet2/13 unassigned YES unset up upGigabitEthernet2/14 unassigned YES unset up upGigabitEthernet2/15 unassigned YES unset up upGigabitEthernet2/16 unassigned YES unset up upGigabitEthernet2/17 unassigned YES unset up upGigabitEthernet2/18 unassigned YES unset up upGigabitEthernet2/19 unassigned YES unset up up

There are many things you can do with Include, which the same as GREP in Unix or ASA.


Hope this helps.