Skip to content

Instantly share code, notes, and snippets.

@stevenocchipinti
Created September 2, 2014 07:17
Show Gist options
  • Save stevenocchipinti/08dad037adbec468eeea to your computer and use it in GitHub Desktop.
Save stevenocchipinti/08dad037adbec468eeea to your computer and use it in GitHub Desktop.
Parse ifconfig
`ifconfig`.split(/^(?=\w)/).flat_map{|x| x.scan(/^(\w+).*inet ([0-9.]+)/m)}
#=> [["lo0", "127.0.0.1"], ["en0", "10.112.202.44"], ["vboxnet0", "192.168.59.3"], ["en4", "10.112.197.80"]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment