Quicker way of reading an input file? Script or Perl?

Quicker way of reading an input file? Script or Perl?

 

  

Hi all,
Am trying to cleanup my ALERT log file which has about 180000+ lines, roughly 8MB.
I have to read each line of the file and then check for the date line. The month and year are normally on the same position if it is indeed a date line. An example of a date line is [Thu Aug 11 16:21:46 2005] excluding the braces. Using awk I always look for fields 2 and 5 and I use that to decide that this is a date line.
If it is, then I echo that line to a AUG_2005.TXT file based from the previous example dateline. So I written a Korn shell script to do a while read line and parse each line and the succeeding lines after that line but before the next date line if the next date line does not have the same month / year as the current date line. So if my ALERT log have
1 Thu Aug 11 16:21:51 2005
2 ARC0: Completed archiving log 4 thread 1 sequence 132097
3 Thu Aug 11 16:22:41 2005
4 Completed checkpoint up to RBA [0x20402.2.10], SCN: 0x0000.2b720a27
5 Thu Aug 11 16:22:41 2005
6 Beginning log switch checkpoint up to RBA [0x20403.2.10], SCN: 0x0000.2b72342e
7 Thu Sep 11 16:22:41 2005
8 ARC0: Evaluating archive log 2 thread 1 sequence 132098
9 ARC0: Beginning to archive log 2 thread 1 sequence 132098
10 Creating archive destination LOG_ARCHIVE_DEST_1: '/u06/backup/archivelog/arch0000132098.arc'

Then lines 1-6 go to AUG_2005.TXT and line 7-10 go to SEP_2005.TXT. Then at the end of parsing the whole ALERT log file, I strip the 180000+ file and retain only the current month's log using sed -n 1,Xp.
Anyway, my script is sort of working, albeit slow. It took about 1.5 hours to parse thru the whole file.
Knowing that these two (2) forums are more likely to have script writers/programmers. I just want to know if there is a quick way of READING the whole chunks of 180000+ lines file into memory and parse it from there. If so, how? Can I do this via the Korn shell script or do I have to use Perl or a C program to do so? If Perl or C is the preferred method, does anyone have an example on how to do this. I can re-write the script in Perl and read the lines one by one as it is with the Korn Shell Script but then I'll end up with the similar scenario.
Any inputs or suggestion will be very much appreciated. Thanks in advance ...



DB2 & UDB email list listserv db2-l LazyDBA home page