Rotate log files

I have a big log,separated by the character:,

[LEFT]one of the fields is the date in the format "day / month / year"

[LEFT]and I need to remove the lines prior to 30 days. Can help me?
[/LEFT]
[/LEFT]

Post an example of the input, desired output and use CODE-tags (might want to use the #-button in the edit bar up there) when doing so, ty.

A example, input is:

prueba|20/05/2009|00:00:02|NODO_STATUS|UP|

[LEFT]I need to delete the file from the previous one month. If today is day July 30, I need to delete the entries prior to June 30

Thanks,
[/LEFT]

I asked you to use code tags and explained how to do. Next time use them please. If you don't understand what I am talking about, please say so.

That excerpt is very short but I think I got it. Maybe it's easier to use something like "ranges" in sed or awk if you take over the part of looking up where the 30 days ago start, so you can skip calculating the last 30 days. Example:

Input

prueba|14/03/2009|00:00:02|NODO_STATUS|UP|
prueba|21/03/2009|00:00:02|NODO_STATUS|UP|
prueba|05/04/2009|00:00:02|NODO_STATUS|UP|
prueba|23/04/2009|00:00:02|NODO_STATUS|UP|
prueba|02/05/2009|00:00:02|NODO_STATUS|UP|
prueba|11/05/2009|00:00:02|NODO_STATUS|UP|
prueba|11/05/2009|00:00:02|NODO_STATUS|UP|
prueba|20/05/2009|00:00:02|NODO_STATUS|UP|

Cmd and output

$> sed '/23\/04\/2009/,/20\/05\/2009/!d' infile
prueba|23/04/2009|00:00:02|NODO_STATUS|UP|
prueba|02/05/2009|00:00:02|NODO_STATUS|UP|
prueba|11/05/2009|00:00:02|NODO_STATUS|UP|
prueba|11/05/2009|00:00:02|NODO_STATUS|UP|
prueba|20/05/2009|00:00:02|NODO_STATUS|UP|

if you work with solaris (9 and later), there is a tool called "logadm" to deal with logfiles...

He posted no filename but a line from a file as it seams. Still he talks about files - not sure what he wants tbh.
If it is for files there might also be the command logrotate on your box.

With gawk you can do something like that :

awk -v Keep=30 -F'|' '

function stime(date   ,d,mdate) {
   split(date, d, "/");
   mdate = d[3] " " d[2] " " d[1] " 00 00 00";
   return mktime(mdate);
}

BEGIN {
   secs_in_day   = 24 * 3600;
   current_stime = systime();
   today_date    = strftime("%d/%m/%Y", current_stime);
   today_stime   = stime(today_date);
   limit_stime   = today_stime - Keep * secs_in_day;
   limit_date    = strftime("%d/%m/%Y", limit_stime);

   print "debug - Today is",today_date;
   print "debug - Keep",Keep,"days";
   print "debug - Keep datas from",limit_date,"included";

}

stime($2) >= limit_stime
' inputfile

Inputfile:

prueba|23/04/2009|00:00:02|NODO_STATUS|UP|
prueba|02/05/2009|00:00:02|NODO_STATUS|UP|
prueba|11/05/2009|00:00:02|NODO_STATUS|UP|
prueba|11/05/2009|00:00:02|NODO_STATUS|UP|
prueba|20/05/2009|00:00:02|NODO_STATUS|UP|
prueba|20/06/2009|00:00:02|NODO_STATUS|UP|
prueba|21/06/2009|00:00:02|NODO_STATUS|UP|
prueba|29/06/2009|00:00:02|NODO_STATUS|UP|
prueba|30/06/2009|00:00:02|NODO_STATUS|UP|
prueba|31/06/2009|00:00:02|NODO_STATUS|UP|
prueba|01/07/2009|00:00:02|NODO_STATUS|UP|
prueba|08/07/2009|00:00:02|NODO_STATUS|UP|

Output:

debug - Today is 30/07/2009
debug - Keep 30 days
debug - Keep datas from 30/06/2009 included
prueba|30/06/2009|00:00:02|NODO_STATUS|UP|
prueba|31/06/2009|00:00:02|NODO_STATUS|UP|
prueba|01/07/2009|00:00:02|NODO_STATUS|UP|
prueba|08/07/2009|00:00:02|NODO_STATUS|UP|

Jean-Pierre.

Use logrotate if it is Linux. You can rotate, remove, compress and mail huge logs.