title: Bash - Passing the wrong value to the function
body: <p>So, writing a bash script see the below code.</p>
  
  <pre><code>allAccessLocations=("/var/www/vhosts/*/logs/access_log" "/var/www/vhosts/*/statistics/access_log" "/var/log/httpd/access_log" "/var/log/httpd/access.log")
  
  checkAccessPaths() {
      for i in ${allAccessLocations[*]};do
          let loopCount++
          local count=$(ls 2&gt;/dev/null $i | wc -l)
          if (( $count &gt; 0 ));then
              local toPass=${allAccessLocations[loopCount -1]}
              echo "this is what should be passed $toPass" &gt;&gt; $reportlog
              checkApacheIPTest $toPass
          else
              :
          fi
      done
  }
  
  checkApacheIPTest(){
      echo "echo $1 is what is passed" &gt;&gt; $reportlog
  }   
  </code></pre>
  
  <p>This is the below output from the log.</p>
  
  <pre><code>this is what should be passed /var/www/vhosts/*/logs/access_log 
  echo /var/www/vhosts/website1/logs/access_log is what is passed
  
  this is what should be passed /var/www/vhosts/*/statistics/access_log
  echo /var/www/vhosts/*/statistics/access_log is what is passed
  </code></pre>
  
  <p>As you can see it KNOWS what to pass as a string to the next function, however when the directory path " /var/www/vhosts/*logs/access_log is passed to the next function, it automaticlly finds the first folder it can and the variable becomes that instead?</p>
  
  <p>The idea is I'm trying to find out which path the Apache logs are in, as they can be in multiple location in different setups.</p>