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

From: Zaigui Wang (zaigui_at_yahoo.com)
Date: 07/31/03

  • Next message: Sandeep Ghodke: "Veritas Volume Manager problem"
    Date: Thu, 31 Jul 2003 13:52:33 -0700 (PDT)
    To: sunmanagers@sunmanagers.org
    
    

    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:
    rmck
    Mark Scarborough
    Frank Velazquez
    David Foster
    Crist Clark
    Daniel Baldoni
    Bochnik, William J
    Janson.Santos@pinnaclewest.com
    David.markowitz@sspsolutions.com
    mike.salehi@kodak,com

    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
    http://sitebuilder.yahoo.com
    _______________________________________________
    sunmanagers mailing list
    sunmanagers@sunmanagers.org
    http://www.sunmanagers.org/mailman/listinfo/sunmanagers


  • Next message: Sandeep Ghodke: "Veritas Volume Manager problem"