Short Notes on Bash
From PaskvilWiki
Extensions and File Name
$ fullname='/tmp/file.tar.gz' $ filename=$(basename $fullname) $ echo ${filename##*.} >> gz $ echo ${filename#*.} >> tar.gz $ echo ${filename%.*} >> file.tar $ echo ${filename%%.*} >> file
For more options and explanations, see Bash - Shell Parameters Expansion.