Collecting and Filtering Information Using IOS show Commands
Posted: January 17, 2016 Filed under: SWITCH Leave a commentUsing pipes with include, exclude and begin
R1# show processes cpu | include IP Input
71 3149172 7922812 397 0.24% 0.15% 0.05% 0 IP Input
S1# show ip interface brief | exclude unassigned
Interface IP-Address OK? Method Status Protocol
Vlan128 10.1.156.1 YES NVRAM up up
S1# show running-config | begin line vty
line vty 0 4
transport input telnet ssh
line vty 5 15
transport input telnet ssh
!
End
R1# show processes cpu| include IP Input
^
% Invalid input detected at ‘^’ marker.
Using pipes with section and ^
R1# show running-config | section router eigrp
router eigrp 1
network 10.1.192.2 0.0.0.0
network 10.1.192.10 0.0.0.0
network 10.1.193.1 0.0.0.0
no auto-summary
R1# show processes cpu | include ^CPU|IP Input
CPU utilization for five seconds: 1%/0%; one minute: 1%; five minutes: 1%
71 3149424 7923898 397 0.24% 0.04% 0.00% 0 IP Input
Using the redirect and tee options
R1# show tech-support | redirect tftp://192.168.37.2/show-tech.txt
R1# show ip interface brief | tee flash:show-int-brief.txt
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 10.1.192.2 YES manual up up
FastEthernet0/1 10.1.192.10 YES manual up up
Loopback0 10.1.220.1 YES manual up up
R1# dir flash:
Directory of flash:/
1 -rw- 23361156 Mar 2 2009 16:25:54 -08:00 c1841-advipservicesk9mz.1243.bin
2 -rw- 680 Mar 7 2010 02:16:56 -08:00 show-int-brief.txt
Using the append option and the more command
R1# show version | append flash:show-commands.txt
R1# show ip interface brief | append flash:show-commands.txt
R1# more flash:show-commands.txt
Cisco IOS Software, 1841 Software (C1841-ADVIPSERVICESK9-M), Version 12.4(23), RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2008 by Cisco Systems, Inc.
Compiled Sat 08-Nov-08 20:07 by prod_rel_team
ROM: System Bootstrap, Version 12.3(8r)T9, RELEASE SOFTWARE (fc1)
R1 uptime is 3 days, 1 hour, 22 minutes
< output omitted >
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 10.1.192.2 YES manual up up
FastEthernet0/1 10.1.192.10 YES manual up up
- The append option is similar to the redirect option, but it allows you to append the output to a file instead of replacing that file.
- The use of this command option makes it easy to collect the output of several show commands in a text file.
- A prerequisite for this option is that the file system that you are writing to must support “append” operations, so for instance, a TFTP server cannot be used in this case.
- In this example, the content of the file is displayed using the more command.
- A more generic way of filtering is to use the a pipe operator “|” with Cisco IOS show commands, followed by one of the keywords include, exclude, or begin, and then a regular expression. Regular expressions are patterns that can be used to match strings in a piece of text. The pattern to be matched is case sensitive.
- The first example shows only the IP Input CPU process for R1.
- The second example shows only switch S1 interfaces that have an IP addressed assigned.
- The third example shows the running config for switch S1 beginning with the first output line that contains the character string “line vty”.
- The fourth example illustrates that, when using the pipe operator, there must always be at least one space preceding and following it, otherwise it will not be accepted by the IOS CLI.