|
file1
01,13,20050621,12,1
02,123,1231222231231231
08,123
01,13,20050620,12,1
02,123,1231222231231231
08,123
其中02开头的能有二十多万条数据
shell 要将file1中01开头的08结尾重新输出到文件中
while read line
do
code=`echo $line|awk -F"," '{print $1}'`
if [ $code = "01" ];then
dat=`echo $line|awk -F"," '{print $3}'`
i=0
echo $line > ${dat}.txt
elif [ $code = "01" ];then ]
echo $line >> ${dat}.txt
i=`expr $i + 1`
else
echo $line >> ${dat}.txt
fi
done < file1
用这个脚本运行的话 二十万条需要很长时间,请大家帮忙看着优化一下,谢谢!! |
|