Skip to content

Instantly share code, notes, and snippets.

@mimizone
Created February 15, 2019 17:53
Show Gist options
  • Save mimizone/0dac040b92eafb76bbb46cbe4557dfa2 to your computer and use it in GitHub Desktop.
Save mimizone/0dac040b92eafb76bbb46cbe4557dfa2 to your computer and use it in GitHub Desktop.
netstat without netstat
grep -v "rem_address" /proc/net/tcp | awk 'function hextodec(str,ret,n,i,k,c){
ret = 0
n = length(str)
for (i = 1; i <= n; i++) {
c = tolower(substr(str, i, 1))
k = index("123456789abcdef", c)
ret = ret * 16 + k
}
return ret
} {x=hextodec(substr($2,index($2,":")-2,2)); for (i=5; i>0; i-=2) x = x"."hextodec(substr($2,i,2))}{print x":"hextodec(substr($2,index($2,":")+1,4))}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment