获取nginx日志状态码百分比脚本
#!/bin/bash pwd=/app/nginx/logs/access.log for num1 in `cat $pwd | awk '{print $9}' | grep -Ei "^4|^5" | wc -l` do echo 异常状态码总数:$num1 for num2 in `cat $pwd | awk '{print $9}'| wc -l` do echo 请求状态码总数:$num2 k=$(echo "scale=2;$num1 * 100 / $num2"| bc)% echo 异常百分比:$k done done