title: How to define dynamic variable in bash?
body: <p>I would like to have a shell variable that could be dynamically run every time it is refered, for example, i would like to have a variable $countPwd which could return the count of files/dirs in the current directory, it could be defined as:</p>
  
  <pre><code>countPwd=`ls | wc -l`
  </code></pre>
  
  <p>and if I do <code>echo $countPwd</code> it would only show the value when I define the variable, but it won't update automatically when I change my current directory. So how do I define such a variable in bash that the value of it get updated/calculated on the fly?</p>
  
  <p>Update:
  The $PWD is a perfect example of a variable get evaluated in the real time. You don't need to use $() or backticks `` to evaluate it. How is it defined in bash?</p>