blob: 324d3e615f42adeb13186d5c3f481255884f5cba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#!/usr/local/bin/perl
use strict ;
use warnings ;
use Compress::Zlib ;
die "Usage: gzgrep pattern file...\n"
unless @ARGV >= 2;
my $pattern = shift ;
my $file ;
foreach $file (@ARGV) {
my $gz = gzopen($file, "rb")
or die "Cannot open $file: $gzerrno\n" ;
while ($gz->gzreadline($_) > 0) {
print if /$pattern/ ;
}
die "Error reading from $file: $gzerrno\n"
if $gzerrno != Z_STREAM_END ;
$gz->gzclose() ;
}
|