-2

I am writing a script to capture certain lines of config from a cisco device. Unfortunately the buffer keeps getting filled up. So I was wondering if cisco devices can have 2 include statements. For example:

show start | include vpn && protocol

The 2 lines that I need info from do not have anything in common. I want to avoid using 2 commands. Is there a way I can get both lines with one command?

Another cisco-show related questions is if I can limit the output to the first 10 lines, some thing like:

show start | inc first 10
user2883071
  • 960
  • 1
  • 20
  • 50
  • If you're asking about Cisco admin commands you should ask on [sf]. However, your assertion that _'the buffer keeps getting filled up'_ suggests that you're doing something wrong in your code, so maybe posting some code here will help. –  Mar 03 '15 at 02:52

2 Answers2

4

This example shows a logic "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#

Another example uses logic "AND" by using regular expressions:

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#
  • "." means any single character
  • "*" means zero or more instance of preceding character
  • so the pipe basically translate to "C" followed by any character (space/text) then "directly connected"

Hope this helps

nico_cisco
  • 56
  • 3
  • Yes, this helped! After some more research I doubt there is a way of showing the first 10 lines. Thank you very much! – user2883071 Mar 03 '15 at 15:07
-1

For the second part of your question, the only way I can think of is if you set the terminal length to 10 lines.

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--