title: Can I use a variable in a file path in bash? If so, how?
body: <p>I'm trying to write a small shell script to find the most recently-added file in a directory and then move that file elsewhere.  If I use:</p>
  
  <pre><code>ls -t ~/directory | head -1
  </code></pre>
  
  <p>and then store this in the variable VARIABLE_NAME, why can't I then then move this to ~/otherdirectory via:</p>
  
  <pre><code>mv ~/directory/$VARIABLE_NAME ~/otherdirectory
  </code></pre>
  
  <p>I've searched around here and Googled, but there doesn't seem to be any information on using variables in file paths?  Is there a better way to do this?</p>
  
  <p>Edit: Here's the portion of the script:</p>
  
  <pre><code>ls -t ~/downloads | head -1
  read diags
  mv ~/downloads/$diags ~/desktop/testfolder
  </code></pre>