Extract File Basename Without Path and Extension in Bash
- by neversaint
Given file names like these:
/the/path/foo.txt
bar.txt
I hope to get
foo
bar
Why this doesn't work?
#!/bin/bash
fullfile=$1
fname=$(basename $fullfile)
fbname=${filename%.*}
echo $fbname
What's the right way to do it?