# Display specific lines from cisco output

**URL:** <https://forum.ansible.com/t/display-specific-lines-from-cisco-output/29972>\
**Category:** Ansible Project\
**Created:** [March 25, 2019, 11:27am UTC](https://forum.ansible.com/t/display-specific-lines-from-cisco-output/29972 "2019-03-25T11:27:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raheel\_Khilji](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@Raheel\_Khilji](https://forum.ansible.com/u/Raheel_Khilji)\
**Post date:** [March 25, 2019, 11:27am UTC](https://forum.ansible.com/t/display-specific-lines-from-cisco-output/29972/1 "2019-03-25T11:27:47Z")

</div>

I have a situation my script is

hosts: Branch  
gather\_facts: false  
connection: local

tasks:

- name: Facts  
ios\_command:  
commands:

- show inter gi0/0  
register: output

- debug:  
msg: “{{ output.stdout\_lines }}”

## The output is like…

"GigabitEthernet0/0 is up, line protocol is up “,  
" Hardware is CN Gigabit Ethernet, address is d8b1.  
" Description: _ **LAN** _”,  
" MTU 1500 bytes, BW 100000 Kbit/sec, DLY 100 usec, ",

" reliability 255/255, txload 1/255, rxload 1/255",  
" Encapsulation 802.1Q Virtual LAN, Vlan ID 1., loopback not set",  
" Keepalive set (10 sec)“,  
" Full Duplex, 100Mbps, media type is RJ45”,  
" output flow-control is unsupported, input flow-control is unsupported",  
" ARP type: ARPA, ARP Timeout 04:00:00",  
" Last input 00:00:00, output 00:00:00, 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 64000 bits/sec, 46 packets/sec”,  
" 5 minute output rate 81000 bits/sec, 38 packets/sec",  
" 64022727 packets input, 3777167804 bytes, 0 no buffer",  
" Received 7566193 broadcasts (0 IP multicasts)“,  
" 0 runts, 0 giants, 0 throttles “,  
" 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored”,  
" 0 watchdog, 904385 multicast, 0 pause input”,  
" 60376363 packets output, 1696679415 bytes, 0 underruns",  
" 0 output errors, 0 collisions, 0 interface resets",  
" 115659 unknown protocol drops",  
" 0 babbles, 0 late collision, 0 deferred",  
" 0 lost carrier, 0 no carrier, 0 pause output",  
" 0 output buffer failures, 0 output buffers swapped out"

**But how can i display an specific line rather then whole output as i want the lines starts with “5 minute”**

Please Help

---

<div class="post-metadata">

**Author:** ![vincent\_collier](https://avatars.discourse-cdn.com/v4/letter/v/dc4da7/32.png) [@vincent\_collier](https://forum.ansible.com/u/vincent_collier)\
**Post date:** [March 25, 2019, 11:48am UTC](https://forum.ansible.com/t/display-specific-lines-from-cisco-output/29972/2 "2019-03-25T11:48:33Z")

</div>

You could use ansible-network.network-engine's command\_parser. The example is on show interfaces.

I published more example on my github: [https://github.com/kvernNC/cisco\_config\_parser/blob/master/README.md](https://github.com/kvernNC/cisco_config_parser/blob/master/README.md)

---

<div class="post-metadata">

**Author:** ![Raheel\_Khilji](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@Raheel\_Khilji](https://forum.ansible.com/u/Raheel_Khilji)\
**Post date:** [March 25, 2019, 12:51pm UTC](https://forum.ansible.com/t/display-specific-lines-from-cisco-output/29972/3 "2019-03-25T12:51:21Z")

</div>

Can you please explain me in detail because i have tried the solution but failed. Please help me

---

<div class="post-metadata">

**Author:** ![vincent\_collier](https://avatars.discourse-cdn.com/v4/letter/v/dc4da7/32.png) [@vincent\_collier](https://forum.ansible.com/u/vincent_collier)\
**Post date:** [March 25, 2019, 9:03pm UTC](https://forum.ansible.com/t/display-specific-lines-from-cisco-output/29972/4 "2019-03-25T21:03:02Z")

</div>

As I said , the documentation is about what your trying to do : [https://github.com/ansible-network/network-engine/blob/devel/docs/user\_guide/command\_parser.md](https://github.com/ansible-network/network-engine/blob/devel/docs/user_guide/command_parser.md), but on show interfaces with a loop, not on a specific interface.

For your example, without loop, It should be something like this (not tested) :

1°) playbook

hosts: Branch  
gather\_facts: false  
connection: local

tasks:

- name: Facts  
ios\_command:  
commands:

- show inter gi0/0  
register: output

- command\_parser:  
file: “parser\_templates/ios/show\_interfaces.yaml”  
content: “{{ output.stdout.0 }}”

- debug:  
var: input\_rate.matches

- debug:  
var: output\_rate.matches

2°) content of the template:
