title: shell scripting - assigning one variable to another - arrays
body: <p>I have a doubt. When i declare a value and assign to some variable, I don't know how to reassign the same value to another variable. See the code snippet below.</p>
  
  <p>Here is my actual script.</p>
  
  <pre><code>#!/bin/sh
  
  a=AA
  b=BB
  c=CC
  d=DD
  e=EE
  f=FF
  
  alpha_array=(a b c d e f)
  process_array=(proc1 proc2 proc3 proc4)
  array_1=("")
  array_2=("")
  
  display_array() {
  echo "array1 = ${array_1[@]}"
  echo "array2 = ${array_2[@]}"
  }
  
  checkarg() {
  if [[ " ${alpha_array[*]} " == *" $token "* ]]; then
      echo "alphabet contains $token "
      array_1=("${array_1[@]}" "$token")
      $token=${$token}
      echo "TOKEN = $token"
  elif [[ " ${process_array[*]} " == *" $token "* ]]; then
      echo "process contains $token "
      array_2=("${array_2[@]}" "$token")
  else
  echo "no matches found"
  display_array
  exit 1
  fi
  }
  
  for token in $@
  do
     echo $token
     checkarg
  done
  
  display_array
  </code></pre>
  
  <p>Here the below two lines  </p>
  
  <pre><code>$token=${$token}
  echo "TOKEN = $token"
  </code></pre>
  
  <p>should display my output as</p>
  
  <pre><code>TOKEN = AA
  TOKEN = BB 
  </code></pre>
  
  <p>when i run my script with the following arguments. </p>
  
  <pre><code>./build.sh a b proc1
  </code></pre>
  
  <p>Kindly help me out on those 2 lines.</p>