Mellen writes in a comment on a blog post:
Using Bash, there’s also ${file%.*}
to get the filename without the extension and ${file##*.}
to get the extension alone. That is,
file="thisfile.txt"
echo "filename: ${file%.*}"
echo "extension: ${file##*.}"
Outputs:
filename: thisfile
extension: txt