Skip to content

Instantly share code, notes, and snippets.

@veryyoung
Created September 1, 2016 09:13
Show Gist options
  • Select an option

  • Save veryyoung/cb5162df24cd99e02a7ce32b49717ba9 to your computer and use it in GitHub Desktop.

Select an option

Save veryyoung/cb5162df24cd99e02a7ce32b49717ba9 to your computer and use it in GitHub Desktop.
#!/sh/bash
###
### 查询当月的每日 uv 详情, 接收 yyyyMMdd 格式的参数, 默认月份为当月
###
LOG_PATH='/var/log/nginx/'
FILE_PREFIX='access.log-'
month=$1
if [ "$1" == '' ]; then
month=`date -d today +%Y%m`
fi
for file in $(ls $LOG_PATH$FILE_PREFIX$month*); do
uv=`zless $file | awk '{print $1}' | sort | uniq | wc -l`
date=`echo $file | grep -o '[0-9]\+'`
echo "$date: $uv"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment