DarthRater
asked on
Regular expression in Cisco
I'm learning how to use regex, and I can't seem to get a solid answer of some of the functionality. inc
For example, let's say I want to filter the output of sh int status to omit the Duplex and Speed Type column. And I also only want things that say disabled or not connected to show.
I tried sh int status | inc (port|name|status|vlan But that just shows everything.
I then tried sh int status | ex connected (port|name|status|vlan|) and that gives me the filtered output I want, but the columns are unaffected.
Where am I going wrong?
For example, let's say I want to filter the output of sh int status to omit the Duplex and Speed Type column. And I also only want things that say disabled or not connected to show.
Port Name Status Vlan Duplex Speed Type
Gi1/1 Magic A notconnect 200 full 100 10/100/1000-TX
Gi1/2 Magic B notconnect 200 full 100 10/100/1000-TX
Gi1/3 Magic C notconnect 200 full 100 10/100/1000-TX
Gi1/4 Magic D notconnect 200 full 100 10/100/1000-TX
Gi1/5 Magic E notconnect 200 full 100 10/100/1000-TX
Gi1/6 Magic F notconnect 200 full 100 10/100/1000-TX
Gi1/7 Magic G notconnect 200 full 100 10/100/1000-TX
Gi1/8 Magic H notconnect 200 full 100 10/100/1000-TX
Gi1/9 Magic I notconnect 200 full 100 10/100/1000-TX
I tried sh int status | inc (port|name|status|vlan But that just shows everything.
I then tried sh int status | ex connected (port|name|status|vlan|) and that gives me the filtered output I want, but the columns are unaffected.
Where am I going wrong?
The include/exclude commands deal with complete rows (lines) of data, not individual columns.
Cisco IOS supports running some tcp, you might be able to write a tcl script to do what you want. I have NO experience doing that, never found a reason to.
Typically I copy the output in put into notepad++ or excel and edit there.
Typically I copy the output in put into notepad++ or excel and edit there.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.