reading log files (performance issue)
Hi All,
I am reading some logfiles and parsing data and printing to some textfile.
Here is my code
OLDIFS=$IFS
IFS='
' # just a newline, in single quotes
while read data
do
if [ "$data" != " " -a "$data" != "" ]
then
#Parsing the Frontend log file
MSISDN="`echo "$data" | cut -c1-10`"
HOUR="`echo "$data" | cut -c11-16`"
ID_SA_SOURCE="`echo "$data" | cut -c17-34`"
ID_SA_DEST="`echo "$data" | cut -c35-52`"
ID_VIR_PORTAL="`echo "$data" | cut -c53-70`"
NW_BEARER="`echo "$data" | cut -c71-74`"
TERMINAL_TYPE="`echo "$data" | cut -c 75-75`"
TRADE_MODEL="`echo "$data" | cut -c 76-105`"
HOUR=$LOGDATE$HOUR
echo $HOUR";"$MSISDN";"$ID_SA_SOURCE";"$ID_SA_DEST";
"$ID_VIR_PORTAL";"$NW_BEARER";"$TERMINAL_TYPE";"$T RADE_MODEL >> OFR_Processed_data.txt
fi
done < $TRACKING_LOGDIR/$listdata
In the log file my data is always fixed thats y ia m using cut to get the data.
This code is working perfectly, but performance vice its a big failure.
while reading a logfile with 1 lakh records its taking morethan 2 hours.
Can any one tell y it is taking this much time ? How can i alter my code in a better way ?
Thanks in advance
Subin
|