Searching and Filtering Show Command Output
You can filter output from
show commands to display lines containing a specified string, lines that do not contain
a specified string, or output starting with a line containing a specified string.
The search string is a regular expression consisting of a single character or a string
of characters. You can use special characters to construct complex regular expressions.
Using Special Characters to Construct Complex Regular Expressions
Special characters allow you to construct complex regular expressions to filter output
from
show commands. You can use a regular expression to specify a single character or multiple
characters as a search string. In addition, you can include special characters that
influence the way the software matches the output against the search string. Supported
special characters are listed in the following table.
Special Characters for Regular Expressions
If you want to filter for a special character instead of using the special character as described in the preceding table, enter a backslash ( \ ) before the character. For example, to filter on output containing an asterisk, enter the asterisk portion of the regular expression as "\*".
device# show ip route bgp | include \*
Displaying Lines Containing a Specified String
Use the |
include syntax with a regular expression to
filter the output of any show commands that include the regular expression. In the following
example, the output of the show interfaces tunnel command for tunnel 10 is filtered to display
only lines containing the word "Internet". This command filters the output of
the
show interfaces tunnel command to display only lines that contain the word
"Internet".
device# show interfaces tunnel 10 | include Internet Internet address is 10.11.1.1/31, MTU 1476 bytes, encapsulation GRE
Note that the regular expression specified as the search string is case-sensitive. In the previous example, a search string of "Internet" would match the line containing the IP address, but a search string of "internet" would not.
Displaying Lines that Do Not Contain a Specified String
Use the |
exclude syntax with a regular expression to
filter the output of any show commands that do not match (exclude) the regular expression. In
the following example, the output of the show who command is
filtered to display only the lines that do not contain the word "closed". This
command can be used to display open connections to the RUCKUS device.
device# show who | exclude closed Console connections: established you are connecting to this session 2 seconds in idle Telnet connections (inbound): 1 established, client ip address 10.168.9.37 27 seconds in idle Telnet connection (outbound): SSH connections:
Displaying Lines Starting with a Specified String
Use the |
begin syntax with a regular expression to filter
the output of any show commands to display only output starting with the first line
that starts with a regular expression match. In the following example, the output
of
the show who
command is filtered to display output starting with the first line that contains
the
word "SSH". This command can be used to display information about SSH connections
to
the RUCKUS device.
device# show who | begin SSH SSH connections: 1 established, client ip address 10.168.9.210 7 seconds in idle 2 closed 3 closed 4 closed 5 closed