I currently use grep to find strings in log output. My new task requires that I find multiple entries in individual files. Specifically MAC address entries attached to a switch port. After running an audit to the network (5k+ devices), I am not worried about finding those files with a single MAC being reported coming in on switch port 1 for example. I am needing to find those files, and output that information, for switches that are learning more than 1 MAC on switch port 1.
Ideally, if I can search for all 48 ports in a single line, that would make my job easier. If I do have to go through the list 48 times, that is not the end of the world.
Thank you guys and gals in advance. Apologies, as this is my first question I've ever asked on this platform.
Example of what I currently do:
grep "ge-0/0/2.0" example1.log
INTERNET de:ad:be:ef:00:01 Learn 2:21 ge-0/0/2.0
INTERNET de:ad:be:ef:00:02 Learn 0 ge-0/0/2.0
DATA de:ad:be:ef:01:01 Learn 4:20 ge-0/0/2.0
grep "ge-0/0/20.0" example1.log
POS de:ad:be:ef:02:01 Learn 0 ge-0/0/20.0
grep "ge-0/0/2*.0" example1.log
INTERNET de:ad:be:ef:00:01 Learn 2:21 ge-0/0/2.0
INTERNET de:ad:be:ef:00:02 Learn 0 ge-0/0/2.0
DATA de:ad:be:ef:01:02 Learn 0 ge-0/0/30.0
DATA de:ad:be:ef:01:01 Learn 4:20 ge-0/0/2.0
POS de:ad:be:ef:02:02 Learn 0 ge-0/0/10.0
POS de:ad:be:ef:02:01 Learn 0 ge-0/0/20.0
But going that raw info can get tedious and mistakes get made. All of my switches start with the same 2 letters, so that makes it easier until I look at the output of it. The single line entries like for ge-0/0/20.0 above get easily mixed in.
What I am exactly looking for from the example above would be:
INTERNET de:ad:be:ef:00:01 Learn 2:21 ge-0/0/2.0
INTERNET de:ad:be:ef:00:02 Learn 0 ge-0/0/2.0
DATA de:ad:be:ef:01:01 Learn 4:20 ge-0/0/2.0
grep "ge-0/0/2.0" example1.log
output? – deimos Jun 14 '19 at 15:41grep
, do not use the*
asterics symbol when you mean any number of any characters. Use.*
instead..
stands forany character
and*
stands foranything
. So thegrep "ge-0/0/2.*.0" example1.log
will give youge-0/0/2.0
andge-0/0/20.0
, but notge-0/0/30.0
– deimos Jun 14 '19 at 15:50grep "ge-0/0/2.0" example1.log
already gives you that. What is your question? – deimos Jun 14 '19 at 16:11