Remove content from file

hey all, I have a file with records in following format

8-29-2006 13:01:45|ABC|45
8-29-2006 14:23:12|DEF|21
8-30-2006 00:04:57|ABC|34

I want to remove all yesterday records. Can anyone show me how? Thanks!

Do you mean you want to keep the today's record and removed all the past record ??
or you want to remove only the yester day record keeping all prior record and today's record intact.?

Perl solution:

perl -i.old -ne 'print unless /^8-29/' file

This is supposed to be a daily job, so if I am doing the right job from the beginning then all I need to do should be removing yesterday record. But I guess only keeping today's record and removed all the past reocrds should do as well. Thanks

what my approach is

today=`date '+%m-%d-Y'`
grep -v "$today" file_name >file_name

the problem is I can only modify the file, writing the entries to another file is not an option. Can anyone help?

you can do that if you redirect the out put to the same file , but here you will lose the original file information , i mean the same file will contain the todays log only previous log will be removed .

UUOC-->Useless Use of Cat

what if the file would be bigger than 2048 bytes? I can't use grep then, right?

I have tried jambesh's suggested method, but it seems like I can't do that because when I do the original file will become empty. Why? I have to stick with the original file, because it seems like the file there is some sort of pointer linked to that file, my program will continue to write to that file so if I delete it then i would have to restart the server or something. Please help!

Motor !

You are right the cat was in deed not needed there !