title: Extract file basename without path and extension in bash
body: <p>Given file names like these:</p>
  
  <pre><code>/the/path/foo.txt
  bar.txt
  </code></pre>
  
  <p>I hope to get:</p>
  
  <pre><code>foo
  bar
  </code></pre>
  
  <p>Why this doesn't work?</p>
  
  <pre><code>#!/bin/bash
  
  fullfile=$1
  fname=$(basename $fullfile)
  fbname=${fname%.*}
  echo $fbname
  </code></pre>
  
  <p>What's the right way to do it?</p>