title: How do you compare the value of an array to a variable in bash script?
body: <p>I'm practicing bash and honestly, it is pretty fun. However, I'm trying to write a program that compares an array's value to a variable and if they are the same then it should print the array's value with an asterisk to the left of it.</p>
  <pre class="lang-bash prettyprint-override"><code>#!/bin/bash
  
  color[0]=red
  color[1]=blue
  color[2]=black
  color[3]=brown
  color[4]=yellow
  favorite=&quot;black&quot;
  
  for i in {0..4};do echo ${color[$i]};
  if {&quot;$favorite&quot;=$color[i]}; then
      echo&quot;* $color[i]&quot;
  done
  </code></pre>
  <p>output should be <code>*black</code></p>