代码语言:javascript复制
#!/bin/sh
cd /data/webserver/nginx/logs
read -p "Please Enter setime(eg. '10-15'):" setime
if [ ! $setime ];
then
echo "Input format error"
exit 0
fi
sed -n "/2020-'${setime} '00:00:00/,/2020-'${setime} '23:59:59/p" xxxx_access.log | grep Baiduspider >> "/tmp/2020-${setime}.log"
或者直接导出
代码语言:javascript复制sed -n "/2020-11-03 00:00:00/,/2020-11-03 23:59:59/p" /data/webserver/nginx/logs/xxxx.log | grep Baiduspider >> "/data/www/xxxxx/xxxx.log"