[wplug] bash script need help

W. Banguna wbanguna at gmail.com
Mon Dec 3 21:01:19 EST 2007


On Dec 3, 2007 5:54 PM, Zach <netrek at gmail.com> wrote:

> Hi,
>
> I have a bash script I use to parse out email addresses from log
> files, it doesn't work 100% but is good enough to seperate out most of
> the wheat from the chaf! The problem is it is hardcoded to use one
> filename at a time so I must keep editing the file, changing the
> filename, saving script, running it, etc. Anyone know how I can make
> this script work on any logfile so I can do: email-script.sh foo
>
> email-script.sh:
>
> grep @ /tmp/trekmsglog | grep -v @$ | grep -v \( | grep -vi bomb |
> grep -v \! | grep -v ++ | grep -v crippled | grep -v "has no gas" | grep
> -v 4.4.
> 0.4 | grep -vi "clue game" | grep -v " @$" | grep -v Pick | grep -v
> Carrying | m
> ore


Replace the file name with $1, which means the first argument, or $* to mean
all of the arguments (that way the grep runs over more than one file, if
provided).

You could save a lot of time and processes by using egrep, and all the 'grep
-v' into one expression, delimited by '|', i.e.

egrep -v '@$|bomb|\!|\+\+|crippled' (etc)

-- 
W. Banguna <wbanguna at GMail.COM>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.wplug.org/pipermail/wplug/attachments/20071203/36786476/attachment.html


More information about the wplug mailing list