Created
May 27, 2014 06:49
-
-
Save Aenigma/69c1ad49b5ec0a57cd81 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
#!/usr/bin/env ruby | |
REGEX = %r{TRP.*(\d{2}\/\d{2}\/\d{4} \d{2}:\d{2}:\d{2}).*(\d{2}\/\d{2}\/\d{4} \d{2}:\d{2}:\d{2}).*(\d{2}:\d{2}:\d{2}).*(\d{4}\.\d{2}\.\d{2}\.\d{2}\.\d{2}\.\d{2})} | |
abort "You must enter file paths via CLI" unless ARGV.length > 0 | |
ARGV.each do |file_path| | |
File.open(file_path, "rb") do |f| | |
results = f.read.scan(REGEX) | |
if results.length != 1 | |
puts "File #{f.path} contained #{results.length} instances of pattern}" | |
next | |
end | |
puts results[0][2] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment