Created
December 4, 2014 03:30
-
-
Save anonymous/375b6122bd0143f7f74d to your computer and use it in GitHub Desktop.
This file contains 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
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