?
Solved

Regular expression in Cisco

Posted on 2014-01-22
3
Medium Priority
?
356 Views
Last Modified: 2014-01-22
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.

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

Open in new window



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?
0
Comment
Question by:DarthRater
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 57

Expert Comment

by:giltjr
ID: 39800108
The include/exclude commands deal with complete rows (lines) of data, not individual columns.
0
 
LVL 57

Expert Comment

by:giltjr
ID: 39800115
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.
0
 
LVL 11

Accepted Solution

by:
Miftaul earned 2000 total points
ID: 39800128
Regular expressions can not filter out the column, you need TCL to do that.

You can customize this example script to achieve your need - Link Here
0

Featured Post

Automating Your MSP Business

The road to profitability.
Delivering superior services is key to ensuring customer satisfaction and the consequent long-term relationships that enable MSPs to lock in predictable, recurring revenue. What's the best way to deliver superior service? One word: automation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
This article is in regards to the Cisco QSFP-4SFP10G-CU1M cables, which are designed to uplink/downlink 40GB ports to 10GB SFP ports. I recently experienced this and found very little configuration documentation on how these are supposed to be confi…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question