More on cisco command output filteringWednesday, May 21, 2014 - by Keith A. Smith
Finding the right piece of information that you need from a Cisco router can often be a challenge. For example, if you use the show running-config command on a large production router, you can easily end up with 25 pages of text output.
Locating that one piece of information you're looking for can take a lot of time. Once you find it, you might need to make a change, only to have to rerun the command and go through the whole process again. However, there are some shortcuts you can take to find this information more quickly. Let's looks at some filtering options you can use when maneuvering through long command output on a Cisco router. Filter output using line numbersYou can use the show running-config linenum command to configure the system to include line numbers at the start of each line in the output. Here's an example: Current configuration : 59161 bytes Once you have line numbers to use as reference points, you can then filter the output by starting at a certain line or only returning a specified line. Here's an example of starting the output at a specific line: Router# show running-config linenum | begin 6 : Here's an example of requesting only one line returned in the output: Router# show running-config linenum | include ( 6 : ) Filter output using Include, Exclude, or BeginYou can also use certain commands to help filter your output. For example, you can use the include command to see only lines that include the word service. Here's an example: Router# show running-config | include service service tcp-keepalives-in service tcp-keepalives-out service timestamps debug datetime msec localtime show-timezone service timestamps log datetime msec localtime show-timezone service password-encryption You can use the begin command to start the output at a certain line (such as an interface). Here's an example: Router# show running-config | begin interface Serial3/0 interface Serial3/0 In addition, you can use the exclude command in the same way if there's something particularly long that you don't need to see in the output. The best thing about these three commands is that they work with almost any output on the router. For example, let's say I wanted to see all routes that begin with the IP address 10.83.x.x. But it doesn't work if I use this: Router# show ip route 10.83.0.0 % Subnet not in table However, if I use something like the following example, I can see all of the routes that begin with 10.83.x.x: Router# show ip route | include 10.83. O 10.83.100.8/30 [110/2370] via 10.83.100.2, 05:32:27, Serial1/2:0.83 O 10.83.100.4/30 [110/2115] via 10.20.100.2, 05:32:27, Serial1/2:0.2 C 10.83.100.0/30 is directly connected, Serial1/2:0.83 O 10.83.103.0/24 [110/2195] via 10.83.100.2, 05:32:27, Serial1/2:0.83 Filter output by interfaceOn the other hand, if you only need to see the output of one specific interface, you can also filter output in that way. Here's an example: Router# show running-config interface Serial3/0 Building configuration... Current configuration : 209 bytes ! Start searching your outputDid you know that you can search directly from the show running-config command's output? If you use the show running-config command, you should see a –More– prompt at the end of each page of output (depending on your page length). If you enter a forward slash [/] at this prompt, it will replace the prompt with the slash, and you can then type in whatever you want to search for. Press [Enter], and it will say filtering and then begin showing you the results of your search. (This is exactly how the UNIX pg command works.) Here's an example: /interface Serial3/0 filtering... interface Serial3/0 |
Tweet |