I have this input file that I need to remove lines which represents more than 30 days of processing.
Input file:
On 11/17/2009 at 12:30:00, Program started processing...argc=7
Total number of bytes in file being processed is 390
Message buffer of length=390 was allocated successfully
Number of bytes read from input file is 121756 = 390
Number of bytes put = 390
Total Number messages = 1
On 11/17/2009 at 12:30:00, Program has completed processing. RC = 0
****************************************************************************
On 05/05/2010 at 12:30:00, Program started processing...argc=7
Total number of bytes in file being processed is 390
Message buffer of length=390 was allocated successfully
Number of bytes read from input file is 121756 = 390
Number of bytes put = 390
Total Number messages = 1
On 05/05/2010 at 12:30:00, Program has completed processing. RC = 0
****************************************************************************
Output file should look like this:
On 05/05/2010 at 12:30:00, Program started processing...argc=7
Total number of bytes in file being processed is 390
Message buffer of length=390 was allocated successfully
Number of bytes read from input file is 121756 = 390
Number of bytes put = 390
Total Number messages = 1
On 05/05/2010 at 12:30:00, Program has completed processing. RC = 0
****************************************************************************
On a previous thread, I have used the below lines of code to check on the date on the line if it is greater than or equal to 30 and to print a number of lines when the date condition was met.
Days=30
Before=$(printf "%4d%02d%02d" $(datecalc -a $(date +'%Y %m %d') - ${Days}))
awk -F '[/ ]*' -v Before=${Before} '
{
date = $4 $2 $3;
if (date >= Before) {
print;
printSepLine = 7;
}
}
/^\*+/ && printSepLine {
print;
printSepLine = 0;
}
' log
However I'm getting this result:
Total number of bytes in file being processed is 390
Message buffer of length=390 was allocated successfully
Number of bytes read from input file is 121756 = 390
Number of bytes put = 390
Total Number messages = 1
****************************************************************************
On 05/05/2010 at 12:30:00, Program started processing...argc=7
Total number of bytes in file being processed is 390
Message buffer of length=390 was allocated successfully
Number of bytes read from input file is 121756 = 390
Number of bytes put = 390
Total Number messages = 1
On 05/05/2010 at 12:30:00, Program has completed processing. RC = 0
****************************************************************************
The block of lines in between dates that were older than 30 days were retained from the output (blue lines above). How do I delete those block of lines?