Skip to content

Instantly share code, notes, and snippets.

@flavio
Created April 17, 2013 10:24
Show Gist options
  • Select an option

  • Save flavio/5403272 to your computer and use it in GitHub Desktop.

Select an option

Save flavio/5403272 to your computer and use it in GitHub Desktop.
Small ruby script made for my friend Renato
#!/usr/bin/env ruby
groups = Hash.new{|h,k| h[k] = []}
File.read('foo').lines.each do |line|
ip = line.split(/\s+/).first
next if ip.empty? || ip.nil?
root = ip.split('.')[0,2].join('.')
groups[root] << line.chomp
end
puts groups.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment