Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 May 2004 08:13:41 -0700
From:      Drew Tomlinson <drew@mykitchentable.net>
To:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   grep & RegEx Syntax- How to Match?
Message-ID:  <40A8D6A5.5090705@mykitchentable.net>

next in thread | raw e-mail | index | archive | help
I've learned a little about regular expressions and am trying to use 
them with grep.  I want to parse my httpd log to return entries that 
contain a particular IP address and file ending in .htm or .html.  I 
want to match lines like this one:

123.456.789.123 - - [17/May/2004:06:54:53 -0700] "GET 
/public/murphys/produced/tricks.html HTTP/1.0" 200 5446 "-" 
"Mozilla/4.77 [en] (X11; U; Linux 2.2.19 i686)"

I'm using the this command:

egrep -e ^123\.456\.789\.123.*htm.* /path/to/file

However this does not match anything.  If I shorten the regex to 
^123\.456\.789\.123, I match all entries with that IP address.  And if I 
use 'htm' as the regex, I get match all lines with html files.  But I 
can't find the right syntax to match on both conditions.

Thanks for your help!

Drew

-- 
Visit The Alchemist's Warehouse
Magic Tricks, DVDs, Videos, Books, & More!

http://www.alchemistswarehouse.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?40A8D6A5.5090705>