Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Webcast-Catalyst9k
Bronze

IOS feature request - Show x | begin n

Is there a way to use the show x | begin n command to show a certain number of lines in the config above the line with the requested keyword? Is there a way to do a regex command to do it.

For example:

Config=

int vlan 42

description Voice Servers

ip address 10.100.1.1 255.255.255.0

int vlan 45

description Database Servers

ip address 10.1.1.1 255.255.255.0

I want to see what VLAN is for database servers. I issue the command 'show run | begin Database' and get the below output.

description Database Servers

ip address 10.1.1.1 255.255.255.0

----- truncated config -----

This still doesn't tell me the VLAN. I know I can do a 'sho ip int brief' command to get the VLAN, but it would be nice to be able to get it without needing to issue another command. like the below example.

'show run | begin Database | lines 3'

ip address 10.100.1.1 255.255.255.0

int vlan 45

description Database Servers

ip address 10.1.1.1 255.255.255.0

----- truncated config -----

Now I can see the interface with that IP without needing to enter another command. This is a simplified example, but I have experienced commands that this would have come in handy especially for ASA firewall object-groups. If I search on a member IP, I can't see the object-group name that it is a member of because it is higher in the config than the line that contains the member IP address.

What are your thoughts on this? I know there's other ways of finding information contained in config files, but thought it would be useful to be able to include lines prior to the one that contains the keyword used for matching.

Thank you,
Mark

Everyone's tags (3)
5 REPLIES
Hall of Fame Super Gold

IOS feature request - Show x | begin n

If I have to do what you are searching, which I do often, I use the command "sh interface desc".

Bronze

IOS feature request - Show x | begin n

Leo,

I appreciate the reply, but as I stated in the post, I used a simplified example and wasn't necessarily looking for interface descriptions. I was asking about its usefulness in general. I mentioned another example of where this would be handy with ASA firewalls. I don't have an example off the top of my head, but will update the next time I identify a time when it would have been useful.

Thank you,

Mark

Hall of Fame Super Gold

IOS feature request - Show x | begin n

LOL.

Nah.  Not as far as I'm aware.  You'll need to be very good at regular expressions to get what you want. 

IOS feature request - Show x | begin n

hi mark,

you'll need to manually check from switch using show vlan id x or show vlan brief and check from the router for the GW IP with show ip interface brief or show run interface x.

Bronze

IOS feature request - Show x | begin n

John,

Thanks for the reply, but the example given was for example only. I am not necessarily looking for that information. What I think would be nice is if you could run a show command with the 'include' or 'begin' option and also state to show x number of lines of configuration above the line that matches the keyword.

Again, I am not looking for specifically interface configuration information. It is for example only.

Thank you,

Mark

270
Views
0
Helpful
5
Replies
CreatePlease to create content