Unix Programming - shell script to trim log file

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > May 2005 > shell script to trim log file





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author shell script to trim log file
manoj

2005-05-19, 2:48 am

I am seeking a shell script which can trim a log file based on the
date ( date string appears in every line of log file) and trimmed
portion of log shoule stored in a new file.

regards
Manoj

SM Ryan

2005-05-19, 7:48 am

"manoj" <manoj.kushwaha@gmail.com> wrote:
# I am seeking a shell script which can trim a log file based on the
# date ( date string appears in every line of log file) and trimmed
# portion of log shoule stored in a new file.

If the date filter is simple enough to be handled by a regular expression,
you can use egrep. For example for ISO dates, 1 March till yesterday are

2005-(0[34]-[0-3][0-9]|05-(0[1-9]|1[0-8]))

You can also do slightly more complicated date parsing with awk and
use that as a filter.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
I love the smell of commerce in the morning.
mark.westwood@gmail.com

2005-05-19, 7:48 am

Manoj

You might find that what you want to achieve is easier done with the
logrotate utility.

Regards
Mark

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com