Skip to content

Instantly share code, notes, and snippets.

@rdemoraes
Created November 9, 2021 02:08
Show Gist options
  • Save rdemoraes/913639282ead2800c2bcbbdb3f634bf4 to your computer and use it in GitHub Desktop.
Save rdemoraes/913639282ead2800c2bcbbdb3f634bf4 to your computer and use it in GitHub Desktop.
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