Commit | Line | Data |
319fab50 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict ; |
dc82791d |
4 | use warnings ; |
319fab50 |
5 | use IO::Uncompress::Bunzip2 qw($Bunzip2Error); |
6 | |
7 | die "Usage: gzgrep pattern [file...]\n" |
8 | unless @ARGV >= 1; |
9 | |
10 | my $pattern = shift ; |
11 | my $file ; |
12 | |
13 | @ARGV = '-' unless @ARGV ; |
14 | |
15 | foreach $file (@ARGV) { |
16 | my $gz = new IO::Uncompress::Bunzip2 $file |
17 | or die "Cannot uncompress $file: $Bunzip2Error\n" ; |
18 | |
19 | while (<$gz>) { |
20 | print if /$pattern/ ; |
21 | } |
22 | |
23 | die "Error reading from $file: $Bunzip2Error\n" |
24 | if $Bunzip2Error ; |
25 | } |