title: Bash If statement within while loop executes even when condition not met
body: <p>I have been using a bash script within ChromeOS to record screen brightness every 5 minutes as well as change and record the brightness if it changes.</p>
  <pre><code>#!/bin/sh
  
  #This script will collect brightness every 5 minutes
  #If brightness is not at desired setting, script will correct and note time changed
  
  i=13
  time=$(date +%H%M)
  bright=$(backlight_tool --get_brightness_percent)
  
  echo &quot;start time is &quot;$time &gt;&gt; brightness_log.txt
  while [ $i -ne 1 ]; do
  
      sleep 300 
      backlight_tool --get_brightness_percent &gt;&gt; brightness_log.txt
      i=$(( $i-1 ))
  
          if [ $bright != 60.5 ]; then
              backlight_tool --set_brightness_percent=60.5
              echo &quot;Brightness changed at &quot;$time &gt;&gt; brightness_log.txt
          else
              break
          fi 
  done
  exit
  </code></pre>
  <p>The script works, however even when brightness is 60.5, the if statement will execute and echo &quot;Brightness changed at &quot; with the same repeated time.</p>
  <p>If the brightness IS equal to 60.5, why is the if statement executing and not skipping to the break?</p>