title: Bash script error with cat and if
body: <p>I'm learning bash but now I'm having a lot of trouble making this script work: </p>
  
  <pre><code>#!/bin/bash
  
  A="0"
  B="0"
  C="0"
  D="0"
  E="0"
  F="0"
  G="0"
  
  while true; do
  
  sleep 1
  
  BATTERY='cat battery.txt'
  
  if [["$BATTERY" -le 100] &amp;&amp; ["$BATTERY" -gt 85] &amp;&amp; [$A -eq 0]]; then
  
  A="1"
      commands... 
  
  elif [["$BATTERY" -le 85] &amp;&amp; ["$BATTERY" -gt 70] &amp;&amp; [$B -eq 0]]; then
  
  B="1"
      commands...
  
  elif [["$BATTERY" -le 70] &amp;&amp; ["$BATTERY" -gt 55] &amp;&amp; [$C -eq 0]]; then
  
  C="1"
      commands...
  
  elif [["$BATTERY" -le 55] &amp;&amp; ["$BATTERY" -gt 40] &amp;&amp; [$D -eq 0]]; then
  
  D="1"
  commands...
  
  elif [["$BATTERY" -le 40] &amp;&amp; ["$BATTERY" -gt 25] &amp;&amp; [$E -eq 0]]; then
  
  E="1"   
      commands...
  
  elif [["$BATTERY" -le 25] &amp;&amp; ["$BATTERY" -gt 10] &amp;&amp; [$F -eq 0]]; then
  
  F="1"
  commands...
  
  elif [["$BATTERY" -le 10] &amp;&amp; ["$BATTERY" -gt 0] &amp;&amp; [$G -eq 0]]; then
  
  G="1"
  commands...
  fi
  done
  </code></pre>
  
  <p>The error that I get when I execute this script is:</p>
  
  <pre><code>./changewill.sh: line 17: [[cat battery.txt: command not found
  ./changewill.sh: line 27: [[cat battery.txt: command not found
  ./changewill.sh: line 36: [[cat battery.txt: command not found
  ./changewill.sh: line 45: [[cat battery.txt: command not found
  ./changewill.sh: line 54: [[cat battery.txt: command not found
  ./changewill.sh: line 63: [[cat battery.txt: command not found
  ./changewill.sh: line 72: [[cat battery.txt: command not found
  </code></pre>
  
  <p>I have been reading and looking around and I think the <code>cat</code> output is correctly assigned to BATTERY. I tried with some different things like <code>{</code> <code>[</code> <code>¨</code>, but nothing works.
  And yes, the file exists and it's in the same folder with the script.</p>
  
  <p>Any advice?</p>