[vox-tech] bash scripting question

Nick Schmalenberger nick at schmalenberger.us
Wed Apr 25 21:55:27 PDT 2007


On Wed, Apr 25, 2007 at 08:28:40PM -0700, Cylar Z wrote:
> Hey programming gurus...
>  
> I want to write a script which takes a block of text
> and extracts any numbers which match a 123.456.789.012
> pattern. I am not looking for any numbers in
> particular (so I don't think the grep command will be
> of much help) but rather, any set of numbers that
> looks like an IP address. 
> 
> Basically the script is to look through some log files
> and find all of the IP numbers listed there. Having
> accomplished this, the script is to compile a list of
> the numbers it finds by redirecting the output to a
> text file. I'm planning to set this up as a
> supplemental automatic log-scanning tool that will run
> nightly as a cron job.
> 
> Could sed or awk be of use here? Not intimately
> familiar with either, but I have heard they are
> powerful text-processing tools. I can research them on
> my own if you guys think I should go that route. I'm
> sure this is a simple task but I'm too green to know
> where to start.
> 
> Your thoughts, please.
> 
> Thanks,
> Matt
> 
This thread might help you:
http://www.perlmonks.org/?node_id=395990
but you should also look at the logwatch program, I think it does a
pretty good job of generating reports for various log files.
Nick Schmalenberger


More information about the vox-tech mailing list