another nice one-liner , glans at connection stats

user@computer $: netstat -an | awk ‘/^tcp/ {A[$(NF)]++} END {for (I in A) {printf “%5d %s\n”, A[I], I}}’
78 TIME_WAIT
3 CLOSE_WAIT
16 FIN_WAIT1
213 ESTABLISHED
1 SYN_RECV
1 LAST_ACK
15 LISTEN

One thought on “another nice one-liner , glans at connection stats

  1. Doesn’t work for me.
    in the iTerm it is even impossible to paste the line.

    In the standard Mac terminal:

    netstat -an | awk ‘/^tcp/ {A[$(NF)]++} END {for (I in A) {printf ā€œ%5d %s\nā€, A[I], I}}’
    awk: syntax error at source line 1
    context is
    /^tcp/ {A[$(NF)]++} END {for (I in A) {printf >>> ? <<<
    awk: illegal statement at source line 1

Leave a comment