title: Read a config file in BASH without using "source"
body: <p>I'm attempting to read a config file that is formatted as follows:</p>
  
  <pre><code>USER = username
  TARGET = arrows
  </code></pre>
  
  <p>I realize that if I got rid of the spaces, I could simply source the config file, but for security reasons I'm trying to avoid that.  I know there is a way to read the config file line by line.  I think the process is something like:</p>
  
  <ol>
  <li>Read lines into an array</li>
  <li>Filter out all of the lines that start with #</li>
  <li>search for the variable names in the array</li>
  </ol>
  
  <p>After that I'm lost.  Any and all help would be greatly appreciated. I've tried something like this with no success:</p>
  
  <pre><code>backup2.config&gt;cat ~/1
  
  grep '^[^#].*' | while read one two;do
      echo $two
  done
  </code></pre>
  
  <p>I pulled that from a forum post I found, just not sure how to modify it to fit my needs since I'm so new to shell scripting.</p>
  
  <p><a href="http://www.linuxquestions.org/questions/programming-9/bash-shell-program-read-a-configuration-file-276852/" rel="noreferrer">http://www.linuxquestions.org/questions/programming-9/bash-shell-program-read-a-configuration-file-276852/</a></p>
  
  <hr>
  
  <p>Would it be possible to automatically assign a variable by looping through both arrays?</p>
  
  <pre><code>for (( i = 0 ; i &lt; ${#VALUE[@]} ; i++ ))
  do
      "${NAME[i]}"=VALUE[i]           
  done
  echo $USER
  </code></pre>
  
  <p>Such that calling $USER would output "username"?  The above code isn't working but I know the solution is something similar to that.</p>