Created
July 28, 2009 05:19
-
-
Save ayumin/156946 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 | |
# -*- encoding: utf-8 -*- | |
KeyWord = case ARGV[0] do | |
when "--cpu" then /^CPU used by this session/ | |
when "--cpu" then /^CPU used by this session/ | |
when "--cpu" then /^CPU used by this session/ | |
when "--cpu" then /^CPU used by this session/ | |
end | |
# カレントディレクトリの末尾".txt"で終わる全てのファイルを抽出する | |
# 抽出したファイルからキーワードにマッチする行のみを出力する | |
Dir.glob("*.txt").sort.each do |path| | |
File.open(path,'r') do |file| | |
file.each_line do |line| | |
puts line if line =~ KeyWord | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment