title: Updating a variable inside a loop in bash shell
body: <p>Everytime I run this script, it prints 0 and then aborts with the error</p>
  
  <pre><code>./hw4_1: line 6: syntax error near unexpected token `let'
  ./hw4_1: line 6: `  let COUNTER=0'
  </code></pre>
  
  <p>Source:</p>
  
  <pre><code>#!/bin/bash
  COUNTER=0
  echo $COUNTER
  for i in {$@:2}do
    let COUNTER=0
    while [COUNTER -ne $1]; do
        echo "$i"
        let COUNTER+=1
      done;
  done
  exit
  </code></pre>
  
  <p>I've tried getting rid of let and adding a dollar sign before COUNTER, but no combination of those things work... This bash syntax is killing me.
  Changing 'let COUNTER=0' to COUNTER=0
  just returns the error  </p>
  
  <pre><code>./hw4_1: line 6: syntax error near unexpected token `let'  
  ./hw4_1: line 6: `  let COUNTER=0'
  </code></pre>