Skip to content

Instantly share code, notes, and snippets.

@thinkerbot
Created July 7, 2011 17:08
Show Gist options
  • Save thinkerbot/1070005 to your computer and use it in GitHub Desktop.
Save thinkerbot/1070005 to your computer and use it in GitHub Desktop.
Convert IP addresses to hex from the command line
function ip_to_hex() {
dec=$(echo "$1" | tr '.' ';')
hex=$(echo "obase=16;$dec" | bc)
printf "%02x%02x %02x%02x\n" 0x$hex
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment