shell统计每秒log文件中行数增加值

来源:互联网 发布:软件创业项目容易吗? 编辑:程序博客网 时间:2024/06/05 09:45
DATE=$(date +%s)
count=$(grep -c "" $1)
time=0
sum=0
while true  
do
    DATE_New=$(date +%s)
    if (( $(date +%s) == DATE+1))
    then
        ((time++))
        DATE=$(date +%s)
        count_new=$(grep -c "" $1)
        add=$((count_new - count))
        if [ ! -n "$add" ]
        then
            add=0
        fi
        ((sum = sum + add))
        echo add line number is:$add average:$((sum / time)) 
        count=$count_new
    fi
done
0 0
原创粉丝点击