Cisco Show 命令过滤

Cisco Show command filtering

我正在编写一个脚本来从 cisco 设备捕获某些配置行。不幸的是,缓冲区不断被填满。所以我想知道思科设备是否可以有 2 个 include 语句。 例如:

show start | include vpn && protocol

我需要从中获取信息的 2 行没有任何共同点。我想避免使用 2 个命令。有没有一种方法可以通过一个命令获取两行?

另一个与 cisco-show 相关的问题是我是否可以将输出限制在前 10 行,例如:

show start | inc first 10

这个例子展示了一个逻辑"OR"

R1#show ip int br
Interface                  IP-Address      OK? Method Status                Protocol
Ethernet0/0                unassigned      YES TFTP   administratively down down
Ethernet0/1                192.168.56.11   YES TFTP   up                    up
Ethernet0/2                unassigned      YES TFTP   administratively down down
Ethernet0/3                unassigned      YES TFTP   administratively down down
R1#
R1#show ip int br | inc Ethernet0/0|192.168.56.11
Ethernet0/0                unassigned      YES TFTP   administratively down down
Ethernet0/1                192.168.56.11   YES TFTP   up                    up
R1#

另一个例子通过使用正则表达式来使用逻辑"AND":

R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override

Gateway of last resort is not set

      192.168.56.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.56.0/24 is directly connected, Ethernet0/1
L        192.168.56.11/32 is directly connected, Ethernet0/1
R1#
R1#
R1#show ip route | inc C.*directly connected
C        192.168.56.0/24 is directly connected, Ethernet0/1
R1#
  • “。”表示任何单个字符
  • “*”表示前导字符的零个或多个实例
  • 所以管道基本上转换为 "C" 后跟任何字符 (space/text) 然后 "directly connected"

希望对您有所帮助

对于你问题的第二部分,我能想到的唯一方法就是将终端长度设置为10行。

DeskSwitch#terminal length ?

<0-512> Number of lines on screen (0 for no pausing)

DeskSwitch#terminal length 10

DeskSwitch#sh run

Building configuration...

Current configuration : 12735 bytes

!

! Last configuration change at 14:28:02 CDT Thu May 3 2018 by jerky

! NVRAM config last updated at 23:59:25 CDT Fri Apr 27 2018

!

version 15.2

no service pad

service tcp-keepalives-in

--More--