title: An "and" operator for an "if" statement in Bash
body: <p>I'm trying to create a simple Bash script to check if the website is down and for some reason the &quot;and&quot; operator doesn't work:</p>
  <pre><code>#!/usr/bin/env bash
  
  WEBSITE=domain.example
  SUBJECT=&quot;$WEBSITE DOWN!&quot;
  EMAILID=&quot;an@email.example&quot;
  STATUS=$(curl -sI $WEBSITE | awk '/HTTP\/1.1/ { print $2 }')
  STRING=$(curl -s $WEBSITE | grep -o &quot;string_to_search&quot;)
  VALUE=&quot;string_to_search&quot;
  
  if [ $STATUS -ne 200 ] &amp;&amp; [[ &quot;$STRING&quot; != &quot;$VALUE&quot; ]]; then
      echo &quot;Website: $WEBSITE is down, status code: '$STATUS' - $(date)&quot; | mail -s &quot;$SUBJECT&quot; $EMAILID
  fi
  </code></pre>
  <p>The &quot;-a&quot; operator also doesn't work:</p>
  <pre><code>if [ $STATUS -ne 200 ] -a [[ &quot;$STRING&quot; != &quot;$VALUE&quot; ]]
  </code></pre>
  <p>Could you also please advise when to use:</p>
  <ul>
  <li>single and double square brackets</li>
  <li>parenthesis</li>
  </ul>
  <p>?</p>