Skip to content

Instantly share code, notes, and snippets.

@codeout
Last active February 8, 2016 04:06
Show Gist options
  • Save codeout/42c8090944d55e2f64a7 to your computer and use it in GitHub Desktop.
Save codeout/42c8090944d55e2f64a7 to your computer and use it in GitHub Desktop.
ipv6 to decimal
$ gem install ipaddress
$ ruby -r ipaddress -e "puts IPAddress('2404:6800:400a:804::2004').data.unpack('C16').join('.')"
36.4.104.0.64.10.8.4.0.0.0.0.0.0.32.4
@yuyarin
Copy link

yuyarin commented Oct 21, 2015

mapのところを短く修正
ruby -r ipaddr -e "p IPAddr.new('2404:6800:400a:804::2004').to_string.gsub(':','').scan(/.{2}/).map(&:hex).join('.')"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment