Skip to content

Instantly share code, notes, and snippets.

Created December 4, 2014 03:30
Show Gist options
  • Save anonymous/375b6122bd0143f7f74d to your computer and use it in GitHub Desktop.
Save anonymous/375b6122bd0143f7f74d to your computer and use it in GitHub Desktop.
def ipString(line)
match = line.scan(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)
match.each do |x|
split_array = x.split(".")
return split_array.map{|str| str.rjust(3, '0') }.join '.'
end
end
unless ARGV.size == 1
puts "Invalid number of arguments?"
else
ip_hash = Hash.new(1)
in_file = File.new(ARGV[0], 'r')
in_file.each_line do |line|
ip_string = ipString(line)
puts ip_string
#puts ip_hash[ip_string]+1
end
#puts ip_hash
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment