0

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?

kryger
  • 12,906
  • 8
  • 44
  • 65
makansij
  • 9,303
  • 37
  • 105
  • 183
  • In cygwin you might be using the windows executable named `netstat`. the command `which netstat` will return the full cygwin path of the executable being used. – ShadSterling May 29 '16 at 21:13

1 Answers1

0

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.

Erik Bennett
  • 1,049
  • 6
  • 15