#!/usr/bin/perl -w # Filename: grepc # Purpose: grep for pattern and cut it # Authors: Olaf Klischat # Bug-Reports: see http://grml.org/bugs/ ################################################################################ ################################################################################ # Usage-Examples taken from: # http://groups.google.de/groups?selm=87acw742ea.fsf%40swangoose.isst.fhg.de # get ipaddress of interface ppp0: # $ ifconfig ppp0 | grepc 'inet addr:(.*?)\s' # list all debian packages which have dependency on a given package # $ apt-cache showpkg perl-tk | grepc '(.*?),perl-tk' # list all files which have been changed in comparison to the # cvs repository: # $ cvs diff 2>/dev/null | grepc '^RCS file: (.*?),v$' # get environment variable of a specific process: # $ grepc 'PATH=(.*?)\0' /environ # list destination ports of iptables lol: # $ uris.txt # host2:$ \n"; $re = eval { qr/$re/ } or die "invalid regexp: $@"; while (<>) { if (/$re/) { print "$1\n"; } } ## END OF FILE #################################################################