Summary: get the last line in a file that matches a pattern with sed

From: Zaigui Wang <>
Date: Thu Jul 31 2003 - 16:52:33 EDT
The concensus seems to be just grep the patters from
the file and pipe it out to tail -1. I was hoping for
something fancier, but this will work...

Crist Clark also had this nice awk command:
awk '/<your date pattern>/{last=$0} END{print last}'

Thanks to:
Mark Scarborough
Frank Velazquez
David Foster
Crist Clark
Daniel Baldoni
Bochnik, William J

Zaigui Wang wrote:
> Managers,
> I need to get the last line in a file that matches a
> date pattern (e.g. /03/07/03). How would I do that?
> sed seems to be a good choice. I was able to get a
> paricular line from a file this way with sed: sed -n
> 16p file, but I am open to all solutions that work.
> Any idea?

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
sunmanagers mailing list
Received on Thu Jul 31 16:56:04 2003

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:17 EST