Skip to content

Instantly share code, notes, and snippets.

@ChangJoo-Park
Created April 29, 2014 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChangJoo-Park/11387797 to your computer and use it in GitHub Desktop.
Save ChangJoo-Park/11387797 to your computer and use it in GitHub Desktop.
로그에서 JAVA 부분만 추려서 파일로 쓰고 노트패드를 연다
if ARGV[0] != nil
originFile = ARGV[0]
contentsArray = IO.readlines(originFile)
currentTime = Time.now.strftime("%Y-%m-%d-%H-%M-%S")
targetFile = "#{ARGV[0]}_#{currentTime}.txt"
resultFile = File.open(targetFile, "w")
contentsArray.each do |line|
if (line =~ /JAVA/)
resultFile.write(line)
end
end
resultFile.close
system("notepad #{targetFile}")
else
puts "input log file name argument 0"
puts "example : ruby logfinder.rb (filename)"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment