5-102
Cisco IOS XR Getting Started Guide for the Cisco XR 12000 Series Router
OL-24755-01
Chapter 5 CLI Tips, Techniques, and Shortcuts
Displaying System Information with show Commands
--More--
Filtering show Command Output
Output from the show commands can generate a large amount of data. To display only a subset of
information, enter the “pipe” character (|) followed by a keyword (begin, include, exclude, or file) and
a regular expression. Table 5-3 shows the filtering options for the show command.
In the following example, the show interface command includes only lines in which the expression
“protocol” appears:
RP/0/0/CPU0:router# show interface | include protocol
Null0 is up, line protocol is up
0 drops for unrecognized upper-level protocol
POS0/2/0/0 is administratively down, line protocol is administratively down
0 drops for unrecognized upper-level protocol
POS0/2/0/1 is administratively down, line protocol is administratively down
0 drops for unrecognized upper-level protocol
POS0/2/0/2 is administratively down, line protocol is administratively down
0 drops for unrecognized upper-level protocol
POS0/2/0/3 is administratively down, line protocol is administratively down
Ta b l e 5 - 3 s h o w C o m m a n d Filter Options
Command Description
show command | begin regular-expression
Begins unfiltered output of the show command with the first line that
contains the regular expression.
show command | exclude regular-expression
Displays output lines that do not contain the regular expression.
show command | include regular-expression
Displays output lines that contain the regular expression.
show command | file device0:path/file
Saves output of the show command to the specified file on the specified
device.
show command | utility name
Displays a set of UNIX utilities:
• cut—Cuts characters or lines from the output displayed from standard
input or a file.
• egrep—Searches a file using full regular expressions.
• fgrep—Searches a file for a fixed character string.
• head—Copies bytes or lines at the beginning of the output displayed
from standard input or a file.
• less—Displays the output of a file in a page-by-page manner.
• sort—Sorts, merges, or sequence-checks the output displayed from
standard input or a file.
• tail—Copies the end portion of the output displayed from standard
input or a file.
• uniq—Displays or removes repeated lines in a file.
• wc—Count words, lines, or bytes in a file.
• xargs—Invokes a program from one or more argument lists.