Created
March 21, 2013 12:39
-
-
Save viliampucik/5212724 to your computer and use it in GitHub Desktop.
Perl's zgrep
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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use PerlIO::gzip; | |
my $pattern = $ARGV[0]; | |
my $file = $ARGV[1]; | |
open my $z, '<:gzip', $file or die "gunzip failed: $!\n"; | |
while ( <$z> ) { | |
print if /$pattern/i; | |
} | |
close $z; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you. I was looking for a basic, "How do I quickly open this damn gz file in Perl without too much hassle and googling?" This was it!