TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:9972] Help with Grep



On Wed, 10 Nov 1999, Jonathan Kline wrote:

> 	Basically what I'm trying to do is search through a given file,
> namely /var/log/secure and look for FAILED LOGIN, ROOT LOGIN and refused
> connect.  When the above patterns are found, I want the line containing
> the pattern to be copied to a specified text file.... Does anyone know how
> to do this? IF so is it even possible?

I like Perl for this kind of thing.

while ($line = <STDIN>)
{
	if (grep /foo/, $line) { print OUTPUT $line; }
}

I'm heading to lunch, so the above might not be perfect. But you get the
idea.


-- Chris

  Christopher Reid Palmer : www.innerfireworks.com