Applying Logic To A Subset of File
Posted on 2008-10-01
I have a script that searches a large file, and does arithmetic depending on what it finds.
Its a bit script but the bit of interest is:
for FILE in `ls $FILEMASK`
while read line
if [ $1 = "NUMBER" ]
TOTAL=`expr $TOTAL + $2`
done < $FILE
echo "Total is $TOTAL"
This works on all but the very largest of files.
To make it work for even the largest files, I want to egrep the file, and apply the locgic to the result of the egrep.
I guess I could egrep to a temporary file and change the filemask to process just that file, but is there a way to do it on the fly?