From 9e9b9654241b8db7bff2bc318a1611a91df56ecb Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Tue, 31 Jan 2017 23:53:13 +0100 Subject: [PATCH] Added G. --- G/G | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 6 ++--- README | 4 +++ 3 files changed, 82 insertions(+), 3 deletions(-) create mode 100755 G/G diff --git a/G/G b/G/G new file mode 100755 index 0000000..296c3cf --- /dev/null +++ b/G/G @@ -0,0 +1,75 @@ +#!/usr/bin/perl + +=pod + +=head1 NAME + +G - short hand for multi level greps + + +=head1 SYNOPSIS + +B [[grep options] string] [[grep options] string] ... + + +=head1 DESCRIPTION + +B 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 . + + +=head1 DEPENDENCIES + +B uses B. + + +=head1 SEE ALSO + +B + + +=cut + +my $i = 0; + +while(@ARGV) { + $_ = shift; + push @{$cmd[$i]}, $_; + if(/^[^-]/) { + $i++ + } +} + +exec join"|", map { "grep @$_" } @cmd; + diff --git a/Makefile b/Makefile index af27ec8..51107f7 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ -CMD = blink bsearch histogram upsidedown tracefile timestamp rand rrm goodpasswd gitnext puniq ramusage ramusage +CMD = blink bsearch G histogram upsidedown tracefile timestamp rand rrm goodpasswd gitnext puniq ramusage ramusage -all: blink/blink.1 bsearch/bsearch.1 goodpasswd/goodpasswd.1 histogram/histogram.1 puniq/puniq.1 rand/rand.1 rrm/rrm.1 timestamp/timestamp.1 tracefile/tracefile.1 upsidedown/upsidedown.1 wssh/wssh.1 +all: blink/blink.1 bsearch/bsearch.1 G/G.1 goodpasswd/goodpasswd.1 histogram/histogram.1 puniq/puniq.1 rand/rand.1 rrm/rrm.1 timestamp/timestamp.1 tracefile/tracefile.1 upsidedown/upsidedown.1 wssh/wssh.1 %.1: % pod2man $< > $@ install: mkdir -p /usr/local/bin - parallel -v eval ln -sf `pwd`/*/{} /usr/local/bin/{} ::: $(CMD) + parallel eval ln -sf `pwd`/*/{} /usr/local/bin/{} ::: $(CMD) mkdir -p /usr/local/share/man/man1 parallel ln -sf `pwd`/{} /usr/local/share/man/man1/{/} ::: */*.1 diff --git a/README b/README index c97c97b..8c2f287 100644 --- a/README +++ b/README @@ -10,10 +10,14 @@ field - Split on space. Give the given field number. Supports syntax 1-3,6- forever - Run the same command or list of commands every second. +G - short hand for multi level grep. + gitnext - Checkout next revision. Opposite of 'checkout HEAD^'. neno - No error no output. Only print STDERR and STDOUT if the command fails. +puniq - Print unique lines the first time they are seen. + rand - Generate (pseudo-)random data rclean - Remove files with MD5 sums recorded by rrm (see below).