Created
September 16, 2015 05:02
-
-
Save Matsuyanagi/68e7d22186b9054d6f7a to your computer and use it in GitHub Desktop.
ruby gz file read
This file contains hidden or 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
# gz 圧縮ファイル展開しながら読み込み | |
require 'zlib' | |
filename_gz = "mysql-bin.000004.sql.gz" | |
lineno = 0 | |
Zlib::GzipReader.open( filename_gz ) do |gz| | |
gz.each do |line| | |
lineno += 1 | |
if /reg/i === line | |
puts "#{lineno}: #{line}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment