Netstat continuous refresh (watch changes the output)
Solution 1:
netstat -c
may help you if i've not misunderstood your problem. -c stands for --continuous.
EDIT: there you go:
watch -n 30 "netstat -ntu | awk '{print \$5}' | cut -d: -f1 | sort | uniq -c | sort -n"
I've added a \ before $.
Solution 2:
Searching for command for macos ends up here. For those mac user who want to see the real-time connections of a process:
nettop -p 60683
You can also restrict the interface type, like wifi or wired...
nettop -t wifi -n -p 60683
Solution 3:
Monitoring on Ubuntu 18.04 LTS, this worked well. It displays good human-readable output.
sudo netstat -tupnc
Solution 4:
Just run a while loop that sleeps for 60 seconds
[root@host] $ while true
> do
> netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
> sleep 60
> done
This will give you the same output every 60 seconds