title: Keep x files in a directory and remove any older files
body: <p>This is the command to remove anything more than x files from within  a directory </p>
  
  <pre><code>(ls -t|head -n 5;ls)|sort|uniq -u|xargs rm
  </code></pre>
  
  <p>I would like to how to modify this to do the same from outside the directory using command line</p>