Shell交互输入日期和时间,查询web日志统计条数

##!/bin/sh

dates=$1
month=$(date | awk '{print $2}')
years=$(date | awk '{print $6}')
hours=$2
minutes=$3
seconds=$4


if [ "$seconds" = "" ] && [ "$minutes" = "" ] && [ "$hours" = "" ]; then
        grep "$dates/$month/$years" access.log | grep 'MOBILENO_QUERY'| wc -l;
elif [ "$seconds" = "" ] && [ "$minutes" = "" ]; then
        grep "$dates/$month/$years:$hours" access.log | grep 'MOBILENO_QUERY'| wc -l;
elif [ "$seconds" = "" ]; then
        grep "$dates/$month/$years:$hours:$minutes" access.log | grep 'MOBILENO_QUERY'| wc -l;
else
        grep "$dates/$month/$years:$hours:$minutes:$seconds" access.log | grep 'MOBILENO_QUERY'| wc -l;
fi 

shell-date-weblog.png

参考:

标签: shell

添加新评论