Skip to content

Instantly share code, notes, and snippets.

@Matsuyanagi
Created September 16, 2015 05:02
Show Gist options
  • Save Matsuyanagi/68e7d22186b9054d6f7a to your computer and use it in GitHub Desktop.
Save Matsuyanagi/68e7d22186b9054d6f7a to your computer and use it in GitHub Desktop.
ruby gz file read
# 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