Skip to content

Instantly share code, notes, and snippets.

@emptyset
Created August 11, 2016 20:37
Show Gist options
  • Save emptyset/f97ea4344a1c45d1ad3eedd775c238c6 to your computer and use it in GitHub Desktop.
Save emptyset/f97ea4344a1c45d1ad3eedd775c238c6 to your computer and use it in GitHub Desktop.
#!/usr/bin/awk -f
# ip2dec
BEGIN {
ip = ARGV[1]
split(ip, octets, ".")
for (i = 1; i <= 4; i++) {
dec += octets[i] * 256 ** (4 - i)
}
printf("%i\n", dec)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment