netstat output differences from cygwin to mac

578 views Asked by At

I was trying to parse the output of netstat on my mac today, and I used:

netstat | egrep "*tcp*"

It throws an error for for "operand invaliid", so I tried:

netstat | egrep ".*tcp.*"

...which works great.

Then I tried both of those commands in Cygwin. Neither command returns anything, although neither throws an error. I checked to make sure there were tcp connections, by running netstat by itself.

Why is egrep giving a different result for Mac OS and Cygwin?

1

There are 1 answers

0
Erik Bennett On BEST ANSWER

My cygwin returns uppercase TCP. Have you tried the egrep -i tcp command?

To answer your question, it sounds like the Mac and cygwin have different versions of egrep. In any event, you don't need the wildcards or Kleene star for what you are doing.