From bcf47ae308e4ca8384e651b5a48fad74fc462435 Mon Sep 17 00:00:00 2001 From: sunus Date: Fri, 3 Mar 2017 13:27:11 +0800 Subject: [PATCH] support mac os on mac osx , netstat need to using -p tcp to get only tcp output. tested on osx with bash && zsh linux with bash && zsh --- tcp-connection-state-counter.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcp-connection-state-counter.sh b/tcp-connection-state-counter.sh index 59323ae8..0024851d 100755 --- a/tcp-connection-state-counter.sh +++ b/tcp-connection-state-counter.sh @@ -6,8 +6,8 @@ # $ ./tcp-connection-state-counter.sh # # @author Jerry Lee - -netstat -tna | awk 'NR > 2 { +# on mac osx , netstat need to using -p tcp to get only tcp output. +netstat -tna `[ ! -z $(uname|grep Darwin) ] && echo "-ptcp"` | awk 'NR > 2 { s[$NF]++ }