I am trying to count the amount of connections while groupping them by their 'state'.
This command achieve that goal :
netstat -ant | awk '{ print $6}' | sort | uniq -c
which provide an output that looks like that :
4 CLOSE_WAIT
1 established)
127 ESTABLISHED
1 Foreign
2 LAST_ACK
39 LISTEN
9 TIME_WAIT
I am trying to combine my command with the watch
command like that :
watch -n 1 "netstat -ant | awk '{ print $6}' | sort | uniq -c"
But, the output is just of the netstat -ant
command (and not the last output of the pipe).
How can I use that complex command with watch
?