in reply to Re^2: simple question about printing vars
in thread simple question about printing vars

Something like this?
netstat -ntu | perl -nae 'next unless $F[0] =~ /tcp|udp/; $seen{$F[4]}++ } { @keys = sort { $seen{$b} <=> $seen{$a} } keys %seen; printf "% " . (1 + length($seen{$keys[0]})) . "d %s\n", $seen{$_}, $_ for @keys '

Replies are listed 'Best First'.
Re^4: simple question about printing vars
by httpd (Novice) on Nov 03, 2011 at 13:49 UTC

    thanks. but more complicated :)

    but is it justified to use perl native sort instead of external commands? is it less resource consumable? or faster?

    or is it simpler to compile script without external commands?

    if we go further, then we can even use perl native function for invoke netstat information directly from /proc :)