Slow looping

Looks like I'm hogging the board this morning. This links to my previous thread, but it's a seperate issue so I though I would start a seperate thread. :slight_smile:

I have the following bit of script that works but takes ages to run due to the size of the file (hundreds of thousands of rows of data). Can anyone think of a way to speed up the loop? Thanks in advance. :b:

for results in `grep "^\[$STARTHOUR" ANYOLDFILE | awk -F'|' '{print $4}'`
do
if [ $results -gt 9999 ]
then
(( NUMOFSECONDS[10]=NUMOFSECONDS[10]+1 ))
else
typeset -Z4 results
AMOUNTOFSECONDSFINDER=`echo $results| cut -c1`
(( NUMOFSECONDS[AMOUNTOFSECONDSFINDER]=NUMOFSECONDS[AMOUNTOFSECONDSFINDER]+1 ))
fi
done

No duplicate or cross-posting, please read the rules.

Proceed here:

Thread closed.