Hi all,
I'm playing with a bit of grep and awk, and I'm only interested in finding
out the first result in a grep across files. I'd also like to do it
backwards.
Yeah, alright, okay... So I'm looking for the last time something happened
in the logs... ;)
Example:
fgrep -h "(sshd) session opened" /var/log/messages*
So, that returns the matching lines in messages, messages.1, messages.2,
etc. Trouble is, those files are appended, not prepended (which would be
silly), so grep is finding a series of less recent to more recent results.
What I'd like to do is a reverse grep, thus starting with the most recent
lines and working back. rev just reverses characters...
That's the reverse bit said; I'd also like to return the first match only.
The trouble with piping to head is that it still takes a fair while to go
through all the logs (and this machine has only been up a few weeks). Any
ideas on this one?
Now, before you all jump in and say "PERL!" very loudly, I'd prefer to do
this with one of those "simple tools that do specific things well", such as
awk, grep, etc.
Oh, and for the challenge of course. I almost forgot. As you can see, I've
weenied out already by asking the SLUG list! ;)
- Jeff
-- [EMAIL PROTECTED] -------------------------------------------------
w: http://advogato.org/person/jdub/
i: 16341281 (jdub!)
q: "make: *** No rule to make target `whoopee'. Stop."
--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to [EMAIL PROTECTED] with
unsubscribe in the text