HalloBallo_123 HalloBallo_123 - 3 months ago 39
Perl Question

Regex match line above (Perl)

I want to write a simple script which gives me from a Cisco Configuration every Port which is not in use (shutdown). The shutdown Ports looks always the same like:

interface Ethernet100/1/40

Which Regex can I use to get always the line above 'shutdown' ?
I want to write this script in Perl, please help me.

Answer Source

Turn multiline option on and use this:


That will match the line before the word shutdown.

It's basically looking for a line of any characters ^.+$, looking ahead for some whitespace followed by shutdown.

Try it here: https://regex101.com/r/WFqX5A/1

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download