cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1719
Views
0
Helpful
2
Replies

conditional cli output filter

paolo_carbone
Level 1
Level 1

I have a requirement to filter the next hop information from multiple route-map entries.

e.g. show route-map NAME | section sequence 10

Which gives me the output for sequence 10. I then want to match further to just get the next hop for that sequence so that I can programaically pull the information out.

Is there a way of using & logic at the CLI to make this happen?

Thanks

2 Replies 2

blau grana
Level 7
Level 7

Hi Paolo

I have also searched for this option, but I was able find only opposite possibility.

show route-map NAME | section sequence 10

show route-map NAME | section sequence 10

show route-map NAME | section sequence 10

show route-map NAME | section sequence 10

show route-map NAME | section sequence 10

Router# show running-config | section include interface

interface Ethernet0/0

  shutdown

  no cdp enable

interface Ethernet1/0

  shutdown

  no cdp enable

interface Serial2/0

  shutdown

  no cdp enable

interface Serial3/0

  shutdown

  no cdp enable

This example show every line containing string "interface" and relevant section to that line. The possibility of filtering one line from particular section is not possible by common cisco ios command section filters. Maybe we could accomplish this by some "crazy" regexp it is not my piece of cake.

So if you (or anybody else) find some way how to do it, I will be grateful if you could share it with us.

Best Regards

Please rate helpful posts

Best Regards Please rate all helpful posts and close solved questions

m.glosson
Level 1
Level 1

Not really, because, unlike Linux or Windows cmd, you cannot string pipes together. You can use regular expressions, which sometimes give you what you want. For example, you could use:

show running-config | include ^route-map|next-hop

The first | symbol is a pipe to redirect the output, the second is part of a regular expression meaning "or". This would show you every line that started with "route-map" and every occurrence of "next-hop" which may be what you want or it may not be, based on your configuration.

Matt

Review Cisco Networking for a $25 gift card