title: bash command/script to delete older files version
body: <p>I have 1 directory with a lot of pdf files. 
  This files are generated by another script that renames files with a progressive number for new version: (example)</p>
  
  <pre><code>newyork_v1.pdf
  newyork_v2.pdf
  newyork_v3.pdf
  miami_v1.pdf
  miami_v2.pdf
  rome_v1.pdf
  </code></pre>
  
  <p>The version number is relative to the file, some files are a version 1, someone at version 2 etc like in example.
  Some files stay in version 1 for all own life, some files may grow to 10th version.</p>
  
  <p>After copying this directory in a temp directory I'd like to delete old version for all files, in the example must remain:</p>
  
  <pre><code>newyork_v3.pdf
  miami_v2.pdf
  rome_v1.pdf
  </code></pre>
  
  <p>I try sort and delete by ls and sort command but I do not get the desired result, i try:</p>
  
  <pre><code>ls | sort -k2 -t_ -n -r | tail -n +2 | xargs rm
  </code></pre>
  
  <p>with this command stay only rome_v1.pdf</p>
  
  <p>command or script are indifferent, can anyone help me?</p>