-2

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

show start | include vpn && protocol

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

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

show start | inc first 10
4

2 回答 2

4

此示例显示逻辑“或”

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”,后跟任何字符(空格/文本),然后“直接连接”

希望这可以帮助

于 2015-03-03T08:14:04.147 回答
-1

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

DeskSwitch#终端长度?

<0-512> 屏幕上的行数(0 表示不暂停)

DeskSwitch#终端长度 10

DeskSwitch#sh运行

构建配置...

当前配置:12735字节

!上次配置更改时间为 2018 年 5 月 3 日星期四 14:28:02 CDT,作者:jerky

!NVRAM 配置上次更新时间为 2018 年 4 月 27 日星期五 23:59:25 CDT

15.2 版

没有服务垫

服务 tcp-keepalives-in

- 更多的 -

于 2018-05-03T19:36:27.293 回答