Include begin section in cisco)

Source: Internet
Author: User

The include begin section in cisco first describes the syntax of the router command output filter: Any show command + Pipeline character | + filter. The filters include and exclude: show the rows that contain or do not contain a specific regular expression begin: displays the section from the rows that match the specific regular expression: only display specific sections that conform to the regular expression (the so-called section starts from a line with a non-space header and ends before the next line with a non-space header, the routing protocol configuration command section is commonly used. For more command output, only include, exclude, and begin are supported. Other commands do not support command output filtering, this is different from that of UNIX, which can use pipeline characters for any command, and cannot cascade filtering like UNIX. The following is a simple example of output filtering. The show interface command can output a lot of information, for example: R1 # show interfacesFastEthernet0/0 is up, line protocol is up Hardware is DEC21140, address is ca000000f08.0000 (bia ca000000f08.0000) internet address is 137.1.1.1/27 MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation ARPA, loopback not set Keepalive set (10 sec) half-duplex, 100 Mb/s, 100 BaseTX/fx arp type: ARPA, RP Timeout 04:00:00 Last input never, output 00:00:09, output hang never Last clearing of "show interface" counters never Input queue: 0/75/0/0 (size/max/drops/flushes ); total output drops: 0 Queueing strategy: fifo Output queue: 0/40 (size/max) 5 minute input rate 0 bits/sec, 0 packets/sec 5 minute output rate 0 bits/sec, 0 packets/sec ..... in fact, we may only focus on some information. For example, we usually care about whether all ports work in full duplex mode, that is, Half-duplex., 100 Mb/s, 100 BaseTX/FX, so let's take a look at the filter conditions: R1 # show interfaces | include duplex Half-duplex, 100 Mb/s, 100 BaseTX/FX Half-duplex, 100 Mb/s, 100 BaseTX/FX is much more concise, but not perfect. I found Half duplex, but I don't know which port to use, in the extension, the output is filtered: R1 # show interfaces | include duplex | EthernetFastEthernet0/0 is up, line protocol is up Half-duplex, 100 Mb/s, 100 BaseTX/FXFastEthernet3/0 is administratively down, line protocol is down Half-duplex, 100 M B/s, 100 BaseTX/FX, Which is perfect. Here two pipeline characters are displayed |, followed by this | not to filter the previous results, but to the or function in the regular expression. Isn't it uncomfortable to input so much? Define an alias to simplify it: R1 # conf tEnter configuration commands, one per line. end with CNTL/Z. r1 (config) # alias exec duplex show interfaces | include duplexR1 (config) # endR1 # duplex Half-duplex, 100 Mb/s, 100 BaseTX/FX Half-duplex, 100 Mb/s, 100 BaseTX/FX and then look at the example of a section. Sometimes we only focus on the configuration of the routing protocol on the router, generally, the following command show run | begin router is used to display more configurations in the future, not only including the route configuration, in this case, you can use section filtering (note that not all IOS versions Support section) router1 # show r Un | section routerhostname router1router ospf 100log-adjacency-changesnetwork 0.0.0.0 255.255.255.255 area 0 alas, it is still not perfect. The command for configuring the vro name is also displayed, so you have to modify it again: router1 # sh run | section ^ routerrouter ospf 100log-adjacency-changesnetwork 0.0.0.0 255.255.255.255 area 0 this is perfect. ^ Router indicates the line starting with router. In this way, hostname router1 is discharged from the outside. Finally, let's look at a more complex output filter. In OSPF, show ip ospf neighbor cannot display the area of the neighbor. You can only use the show ip ospf neighbor detail command, Neoshi # show ip ospf neighbor detailNeighbor 172.16.0.21, interface address 172.16.1.2 In the area 0 via interface Serial0/0/0.100 Neighbor priority is 0, State is FULL, 6 state changes DR is 0.0.0.0 BDR is 0.0.0.0 Options is 0x52 LLS Options is 0x1 (LR) Dead timer due in 00:00:37 Neighbor is up for 00:39:02 Index 1/1, retra Nsmission queue length 0, number of retransmission 1 First 0x0 (0)/0x0 (0) Next 0x0 (0)/0x0 (0) last retransmission scan length is 1, maximum is 1 Last retransmission scan time is 0 msec, maximum is 0 msec outputs a lot of information, but in fact the most useful is the output of the first three rows. Neoshi # show ip ospf neighbor detail | include (Neighbor. * (interface | priority) | areaNeighbor 172.16.0.21, interface address 172.16.1.2 In the area 0 via interface Serial0/0/0.100 Neighbor priority is 0, State is FULL, 6 state changesNeighbor 172.16.0.12, interface address 10.0.0.6 In the area 0 via interface FastEthernet0/0 Neighbor priority is 1, State is FULL, 6 state changes this regular expression is a little complicated, but the output still reaches the predefined Value. The above is just a Summary of the command output filtering. In addition to the selection of the filter, the most important thing is the preparation of the regular expression. I will not say much about the regular expression. In fact, the output can be re-formatted to make the output more concise and effective, but this requires the use of TCL scripts. The following is an example of Script output using the alias ipconfig configured by others. If you are interested, you can study it. R1 # ifconfigInterface IP Address Mask MTU State ============================== ================================== FastEthernet0/0 172.18.25.1 255.255.0 1500 upFastEthernet0 /1 no address admin downSerial0/0/0 no address upSerial0/0/0.101 192.168..2 .2 255.255.252 1500 upSerial0/1/0 no address up/down

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.