NR > 1 {
t="echo \"ibase=16;"
substr($2,7,2)"\" |bc"; t | getline a;
close(t);
t="echo \"ibase=16;" substr($2,5,2)"\" |bc";
t | getline b; close(t);
t="echo \"ibase=16;"
substr($2,3,2)"\" |bc"; t | getline c;
close(t);
t="echo \"ibase=16;" substr($2,1,2)"\" |bc";
t | getline d; close(t);
t="echo \"ibase=16;"
substr($2,10,4)"\" |bc"; t | getline e;
close(t);
t="echo \"ibase=16;"
substr($3,7,2)"\" |bc"; t | getline f;
close(t);
t="echo \"ibase=16;" substr($3,5,2)"\" |bc";
t | getline g; close(t);
t="echo \"ibase=16;"
substr($3,3,2)"\" |bc"; t | getline h;
close(t);
t="echo \"ibase=16;" substr($3,1,2)"\" |bc";
t | getline i; close(t);
t="echo \"ibase=16;"
substr($3,10,4)"\" |bc"; t | getline j;
close(t);
if ( a > 0)
printf("%d.%d.%d.%d: %d \t
%d.%d.%d.%d: %d\n",a,b,c,d,e,f,g,h,i,j)
}
Then,
run
cat /proc/net/tcp |awk -f
awktcp.sc1
cat /proc/net/udp |awk -f
awktcp.sc1
You'll get something like the
following:
130 91 96 184 : 22
192 168 1 101 : 2454
192 168 1
101 : 3412
192 168 1 101 : 2155
192 168 1 101 :
2106