title: Bash: Incorrect substring in for loop
body: <p>I'm trying to write a script to check if a string is a palindrome</p>
  
  <pre><code>read str
  l=${#str}-1
  isPal=1
  
  for((i=0;i&lt;=l/2;i++))
  do
      echo "${str:$i,1} :: ${str:$((l-i)),1}"          
      if [[ ${str:$i,1} -ne ${str:$((l-i)),1} ]]; then
              isPal=0
      fi
  done
  
  if [[ $isPal -eq 1 ]]; then
          echo "YES"
  else
          echo "NO"
  fi
  </code></pre>
  
  <p>for an input string: <em>abcdefghi</em></p>
  
  <p>output is:</p>
  
  <pre><code>cdefghi :: bcdefghi
  cdefghi :: bcdefghi
  cdefghi :: bcdefghi
  cdefghi :: bcdefghi
  cdefghi :: bcdefghi
  YES
  </code></pre>
  
  <p>I can't understand what's happening with the substring. I expect it to return me the ith character and the (l-i)th character respectively</p>