#! /bin/sh first=$1 first2=$1 input2=$2 let second=`date -d "-1 days ago ${input2}" +%Y%m%d` second2=$second arr=(1 2 3 4) length=${#arr[@]}; echo "length= ${length}" let length=$length-1 for i in $(seq 0 ${length}); do sum1=0 first=$first2 cmppid=${arr[$i]} echo "cmppid =${cmppid},统计如下:" while [ "$first" != "$second" ] do statistics_num=`cat detail_"$first".txt |grep -E ".*${cmppid}.*" | wc -l` echo detail_"$first".txt statistics_num="$statistics_num" let sum1=$sum1+$statistics_num let first=`date -d "-1 days ago ${first}" +%Y%m%d` done echo "sum1=$sum1" done