I currently have the following bash file, who's job is to update an SVN repository on disk, output the revision number, output the revision data (what changed, by who, revision number, date, etc), update some MySQL databases from the updated content, echo "MySQL updated" and then stop.


cd /var/www/database/svn
svn up
svn log -r HEAD .
svn log --xml --verbose -r HEAD . > /var/www/database/include/svn.xml
cd sql-files/
mysql -u"user" -p"pass" database < item_db.sql
mysql -u"user" -p"pass" database < mob_db.sql
mysql -u"user" -p"pass" database < mob_skill_db.sql
mysql -u"user" -p"pass" database < item_db_re.sql
echo "Updated MySQL databases..." && echo
cd ~
The log outputs:

Tue Feb 14 14:04:41 MST 2012
At revision 15581.
r15581 | user | 2012-02-14 08:29:00 -0700 (Tue, 14 Feb 2012) | 1 line

Removed deprecated memory manager macros (follow-up to r14916).
Updated MySQL databases...

Tue Feb 14 14:35:12 MST 2012
At revision 15582.
r15582 | user | 2012-02-14 14:13:54 -0700 (Tue, 14 Feb 2012) | 1 line

Fixed typo in startup script.
Updated MySQL databases...
This is fine and dandy, it runs in a cron with the following command

/var/www/database/chksvnup.sh >> /var/www/database/include/log.txt
I would like to add some automatic log file management to this script, so that it is capable of cleaning itself up. I don't need a 150KB+ logfile sitting around, but I'd like to keep some data.

I know I'm going to have to use sed for it, I'm just not sure where to start. I want to delete everything in my log file that grows more than 2 months old, by matching the date appended to the file by the bash script and deleting all the lines before that date to the beginning of the file, to make sure it pretty much stays around X amount of KB. Can someone help me out with this? It's a bit out of my league as I've never gotten into bash scripting that much >.<

Thank you in advance for your kind assistance.