Http_statu_code=(`cat ${Log_file_path} |grep -ioE "HTTP\/1\.[0|1]\"[[:blank:]][0-9]{3}" |awk -F"[ ]+" '{
if($2>=100&&$2<200)
{i++}
else if($2>=200&&$2<300)
{j++}
else if($2>=300&&$2<400)
{k++}
else if($2>=400&&$2<500)
{n++}
else if($2>=500)
{p++}
}END{
print i?i:0,j?j:0,k?k:0,n?n:0,p?p:0,i+j+k+n+p
}'
`)
你拿去对一下。
Http_status_codes=(`cat $Logfile_path | grep -ioE "HTTP\/1\.[1|0]\"[[:blank:]][0-9]{3}" | awk -F"[ ]+" '{
if($2>=100&&$2<200)
{i++}
else if($2>=200&&$2<300)
{j++}
else if($2>=300&&$2<400)
{k++}
else if($2>=400&&$2<500)
{n++}
else if($2>=500)
{p++}
}END{
print i?i:0,j?j:0,k?k:0,n?n:0,p?p:0,i+j+k+n+p
}'
`)
$() = ``
/check_http_code.sh: 10: ./check_http_code.sh: Syntax error: "(" unexpected (expecting "}")