title: The 'eval' command in Bash and its typical uses
body: <p>After reading the <a href="https://linux.die.net/man/1/bash" rel="nofollow noreferrer">Bash man pages</a> and with respect to <a href="http://www.unix.com/shell-programming-scripting/66063-eval-shell-scripting.html" rel="nofollow noreferrer">this post</a>, I am still having trouble understanding what exactly the <code>eval</code> command does and which would be its typical uses.</p>
  <p>For example, if we do:</p>
  <pre class="lang-none prettyprint-override"><code>$ set -- one two three  # Sets $1 $2 $3
  $ echo $1
  one
  
  $ n=1
  $ echo ${$n}       ## First attempt to echo $1 using brackets fails
  bash: ${$n}: bad substitution
  
  $ echo $($n)       ## Second attempt to echo $1 using parentheses fails
  bash: 1: command not found
  
  $ eval echo \${$n} ## Third attempt to echo $1 using 'eval' succeeds
  one
  </code></pre>
  <p>What exactly is happening here and how do the dollar sign and the backslash tie into the problem?</p>