Searching for text using pattern matching with show command
Selected portions of the output are displayed, depending on the parameters chosen.
Syntax:
show {< command option > | < include | exclude | begin >} <regular expression>
Uses matching pattern searches to display selected portions of the output from a
show
command. There is no limit to the number of characters that can be matched. Only regular expressions are permitted; symbols such as the asterisk cannot be substituted to perform more general matching.
|
Only the lines that contain the matching pattern are displayed in the output. |
|
Only the lines that contain the matching pattern are not displayed in the output. |
|
The display of the output begins with the line that contains the matching pattern. |
Pattern matching is case-sensitive.
Following are examples of what portions of the running config file display depending on the option chosen.
Pattern matching with include option
switch(config)# show run | include ipv6 1 ipv6 enable ipv6 enable ipv6 access-list "EH-01" switch(config)#
1Displays only lines that contain “ipv6”.
Pattern matching with exclude option
switch(config)# show run | exclude ipv6 1 Running configuration: ; J9299A Configuration Editor; Created on release #YA.15.XX ; Ver #01:01:00 hostname "Switch" mirror-port 4 qos dscp-map 000000 priority 0 qos dscp-map 001000 priority 1 ... interface 1 lacp Active exit interface 6 name "Print_Server" exit ... vlan 1 name "DEFAULT_VLAN" untagged 1-24 ip address dhcp-bootp exit ... port-security 17 learn-mode static address-limit 3 action send-alarm power-over-ethernet pre-std-detect no ip ssh cipher 3des-cbc ip timep dhcp snmp-server community "public" unrestricted snmp-server community "public" unrestricted ... vlan 1 exit
1Displays all lines that do not contain “ipv6”.
Pattern matching with begin option
switch(config)# show run | begin ipv6 1 ipv6 enable no untagged 21-24 exit vlan 20 name "VLAN20" untagged 21-24 ipv6 enable no ip address exit policy qos "michael" exit ipv6 access-list "EH-01" sequence 10 deny tcp 2001:db8:255::/48 2001:db8:125::/48 exit no autorun password manager
1Displays the running config beginning at the first line that contains “ipv6”.
The following is an Example: of the
show arp
command output, and then the output displayed when the
include
option has the IP address of
15.255.128.1
as the regular expression.
The show arp command and pattern matching with the include option
switch(config)# show arp IP ARP table IP Address MAC Address Type Port ------------- -------------- ------- ---- 15.255.128.1 00000c-07ac00 dynamic B1 15.255.131.19 00a0c9-b1503d dynamic 15.255.133.150 000bcd-3cbeec dynamic B1 switch(config)# show arp | include 15.255.128.1 15.255.128.1 00000c-07ac00 dynamic B1