我试图创建一个简单的bash脚本来检查网站是否由于某种原因“和”运算符不工作:
>括号
#!/usr/bin/env bash WEBSITE=domain.com SUBJECT="$WEBSITE DOWN!" EMAILID="an@email.com" STATUS=$(curl -sI $WEBSITE | awk '/HTTP\/1.1/ { print $2 }') STRING=$(curl -s $WEBSITE | grep -o "string_to_search") VALUE="string_to_search" if [ $STATUS -ne 200 ] && [[ "$STRING" != "$VALUE" ]]; then echo "Website: $WEBSITE is down,status code: '$STATUS' - $(date)" | mail -s "$SUBJECT" $EMAILID fi@H_502_3@“-a”操作符也不工作:
if [ $STATUS -ne 200 ] -a [[ "$STRING" != "$VALUE" ]]@H_502_3@你也可以请指教什么时候使用: @H_502_3@>单和双方括号
>括号