shell编程报错 [: missing `]'
NGINX_RATES=50
NGINX_BURST=3000
NGINX_PATH=/opt/srv/nginx/conf/nginx.conf
BEE_PATH=/opt/srv/nginx/conf/vhosts/bee.location
grep -q 'limit_req_zone $server_name zone=lreq:10m rate=' $NGINX_PATH
NGINX_FLAG=$?
if [ "$NGINX_FLAG" = '1' ]; then
sed -i '/limit_zone one $binary_remote_addr 10m;/ a\limit_req_zone $server_name zone=lreq:10m rate='$NGINX_RATES'r/s;' $NGINX_PATH
fi
grep -q 'limit_req zone=lreq burst=' $BEE_PATH
BEE_FLAG=$?
if [ "$BEE_FLAG" = "1" ]; then
sed -i '/ssi_types/ a\limit_req zone=lreq burst='$NGINX_BURST';' $BEE_PATH
fi
今天执行脚本的时候报错
test.sh: line 8: [: missing `]'
test.sh: line 14: [: missing `]'
原因"$NGINX_FLAG"之前和'1'之后都要有空格