title: Remove underscore before extension in strings
body: <p>I have got strings like <code>tran_crossings_exp_.txt</code> and <code>tran_buildings_exp_.shp</code>
  How can I write a bash function to test if the last character before the dot extension starts with an underscore and replace the underscore to have a name like <code>tran_crossings_exp.txt</code> I know how to get the basename and extension of the file in bash</p>
  
  <p>I have done this solution but I am seeking a more elegant way which also check if the file indeed has an underscore and skips it if the name already is proper.</p>
  
  <pre><code>for file in `ls *_.*`;do ext="${file##*.}"; filename="${file%.*}";non=${file::-5}; mv ${file} ${non}.${ext};done
  </code></pre>