Wednesday, July 9, 2014

Neuron: Using grep to return the matched text

I'm working on retiring an old 3080 Cisco VPN Concentrator.  As part of this I'm trying to figure out which L2L tunnels are still in use.  I have the device logging to syslog so it's just a matter of doing some analysis.

One of the things I wanted to do was to return just the part of the syslog that looks like this:

(L2L: <L2L Tunnel Name>)

Obviously I could grep '(L2L: .*)' filename.txt and get all of the lines that have that matched.  But that still left a lot of gunk I didn't need.  Thankfully grep has an answer.  Adding the -o switch to grep results in just the matched text being returned.  I was then able to pipe this to sort and then uniq to get my list of tunnels that had been accessed.

grep -o '(L2L: .*)' filename.txt | sort | uniq

Now comes the hard part of getting contact information for the old tunnels. 

No comments:

Post a Comment