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

Re: [TCLUG:9972] Help with Grep



On Wed, Nov 10, 1999 at 08:18:10AM -0600, 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?

	It's actually pretty easy, and you don't have to use perl.

% grep -E -e '(FAILED LOGIN)|(ROOT LOGIN)|(refused connect)' /var/log/secure >secure.problems.txt

	The paranthesis may, or may not be necessary.  It's a precedence
issue, and my long years of C programming experience have taught me a
lot of caution.  :-)

	There is an excellent O'Reilly book on regular expressions
called 'Mastering Regular Expressions', ISBN: 1565922573.

http://www.oreilly.com/catalog/regex/desc.html

http://www1.fatbrain.com/asp/bookinfo/bookinfo.asp?theisbn=1565922573

	I would give an Amazon link, but they're suing over their
stupidly granted patent on 'one-click shopping', and until they give
up, or lose, I'm boycotting them.

Have fun (if at all possible),
-- 
Its name is Public Opinion.  It is held in reverence. It settles everything.
Some think it is the voice of God.  Loyalty to petrified opinion never yet
broke a chain or freed a human soul.     ---Mark Twain
-- Eric Hopper (hopper@omnifarious.mn.org
                http://ehopper-host105.dsl.visi.com/~hopper) --

PGP signature