cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
88
Views
2
Helpful
1
Replies

Cisco regular expression to filter out IP addresses?

Venison Mogambi
Level 1
Level 1

I'm trying to find a regular expression that works with a show command (such as show ip bgp summary) and only displays the IP addresses in the output, excluding all the other characters. I came up with the following:

show ip bgp summary | include ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$

But when I apply try it, I get no output. Any idea what I'm doing wrong?

1 Reply 1

Harold Ritter
Spotlight
Spotlight

Hi @Venison Mogambi ,

The "include" command can't exclude characters from an output line. It is used to display only output lines matching the regular expression. The resulting output still shows the entire initial output line.

The regular expression you use would only match if the IP address would be the start and end of given output line (line with only an IP address). If you only want to match any output line that includes an IP address, you could use the following:

show ip bgp summary | include [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+

Regards,
Harold Ritter, CCIE #4168 (EI, SP)