Created
July 7, 2011 17:08
-
-
Save thinkerbot/1070005 to your computer and use it in GitHub Desktop.
Convert IP addresses to hex from the command line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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