[root@Aliyun readline]# cat read.sh
#/bin/sh
cd `dirname $0`
#config readline tmp dir
readfile="./aaaa.txt"
mkdir -p /tmp/.readline
workdir="/tmp/.readline"
#读取个数,如果需要发生变化只能是10的倍数
num=100
line_count=`cat $readfile | wc -l`
Stepping=`echo "scale=2; $line_count/$num" | bc`
ZStepping=`echo ${Stepping%.*}`
#Stepping2=`expr $line_count / $num` 这个是整除的不用
#判断是否有小数,对步长进行处理
Zstatus=`echo $Stepping | grep \\. | wc -l`
echo $Zstatus
if [ $Zstatus != 0 ];then
ZStepping=`expr $ZStepping + 1`
fi
echo $line_count
echo $Stepping
echo $ZStepping
function readlinefile(){
#分割文件,将获取到的URL,按照每个文件500
echo readlinefile1
i=1
while true
do
sed -n "${start}p" $readfile >> $workdir/readlinefile.log.$2
if [ $i == $num ];then
echo "readline_num : $i"
echo $start
break
fi
start=`expr $start + 1`
i=`expr $i + 1`
#echo $start
done
}
function loadwork(){
#load function
echo " "
}
function Control(){
for ((j=0;j<=$ZStepping;j++))
do
if [ $j == 0 ];then
start=1
else
start=`expr $j \* $num`
fi
filenum=$j
readlinefile $start $filenum
echo Control1
done
echo Control2
}
Control
#rm -rf /tmp/.readline
#这里有个BUG,在100-101行会被读取2次。未修复