Skip to content

Instantly share code, notes, and snippets.

@jrelo
Forked from viliampucik/pgrep.pl
Created November 9, 2017 22:00
Show Gist options
  • Select an option

  • Save jrelo/218dfd1cfe74016adf68457e8fd35013 to your computer and use it in GitHub Desktop.

Select an option

Save jrelo/218dfd1cfe74016adf68457e8fd35013 to your computer and use it in GitHub Desktop.
Perl's zgrep
#!/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