Extract filename and extension in Bash
The accepted answer works well in typical cases, but fails in edge cases, namely: For filenames without extension (called suffix in the remainder of this answer), extension=${filename##*.} returns the input filename rather than an empty string. extension=${filename##*.} does not include the initial ., contrary to convention.Blindly prepending .
https://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash#comment26516503_965053