script程序运行速度问题
我有一个程序,需要读取一个文件中的每行,然后进行分类操作,但是程序运行速度很慢,不知道怎样来提高一下运行速度,肯求各位达人宝贵建议,程序如下:
SEQ=0
while read "LINE"
do
PAGE_CHECK=`echo "$LINE" | cut -c 1-5`
if [ "$PAGE_CHECK" = "PAGNO" ];then
PAGE_NO=`echo "$LINE" | cut -c 11`
PAGE_1_CHECK=`echo "$LINE" | cut -c 1-6`
if [ "$PAGE_1_CHECK" = "PAGNO1" ];then
SEQ=$(($SEQ + 1 ))
fi
if [ "$SEQ" = "4" ];then
SEQ=1
fi
if [ "$SEQ" = "1" ];then
if [ "$PAGE_NO" = "1" ];then
echo "om987" >> output.DAT
elif [ "$PAGE_NO" = "3" ];then
echo "om988" >> output.DAT
elif [ "$PAGE_NO" = "5" ];then
echo "om989" >> output.DAT
elif [ "$PAGE_NO" = "2" ];then
echo "$LINE" >> output.DAT
elif [ "$PAGE_NO" = "4" ];then
echo "$LINE" >> output.DAT
elif [ "$PAGE_NO" = "6" ];then
echo "$LINE" >> output.DAT
fi
fi
if [ "$SEQ" = "2" ];then
if [ "$PAGE_NO" = "1" ];then
echo "om985" >> output.DAT
elif [ "$PAGE_NO" = "3" ];then
echo "om984" >> output.DAT
elif [ "$PAGE_NO" = "5" ];then
echo "om989" >> output.DAT
elif [ "$PAGE_NO" = "2" ];then
echo "$LINE" >> output.DAT
elif [ "$PAGE_NO" = "4" ];then
echo "$LINE" >> output.DAT
elif [ "$PAGE_NO" = "6" ];then
echo "$LINE" >> output.DAT
fi
fi
if [ "$SEQ" = "3" ];then
if [ "$PAGE_NO" = "1" ];then
echo "om980" >> output.DAT
elif [ "$PAGE_NO" = "3" ];then
echo "om981" >> output.DAT
elif [ "$PAGE_NO" = "5" ];then
echo "om982" >> output.DAT
elif [ "$PAGE_NO" = "2" ];then
echo "$LINE" >> output.DAT
elif [ "$PAGE_NO" = "4" ];then
echo "$LINE" >> output.DAT
elif [ "$PAGE_NO" = "6" ];then
echo "$LINE" >> output.DAT
fi
fi
else
echo "$LINE" >> output.DAT
fi
done < input.DAT
exit 0