tangetools/G/G
2017-01-31 23:53:13 +01:00

76 lines
1.3 KiB
Perl
Executable file

#!/usr/bin/perl
=pod
=head1 NAME
G - short hand for multi level greps
=head1 SYNOPSIS
B<G> [[grep options] string] [[grep options] string] ...
=head1 DESCRIPTION
B<G> is a short hand of writing:
grep --option string | grep --option2 string2
=head1 EXAMPLE
Grep for lines with Foo but not Bar:
G Foo -v Bar
=head1 AUTHOR
Copyright (C) 2017 Ole Tange,
http://ole.tange.dk and Free Software Foundation, Inc.
=head1 LICENSE
Copyright (C) 2012 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
at your option any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
=head1 DEPENDENCIES
B<G> uses B<grep>.
=head1 SEE ALSO
B<openssl>
=cut
my $i = 0;
while(@ARGV) {
$_ = shift;
push @{$cmd[$i]}, $_;
if(/^[^-]/) {
$i++
}
}
exec join"|", map { "grep @$_" } @cmd;