Extract directory, filename, and extension in Bash shell

Extract directory, filename, and extension in Bash shell https://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash $> FILE_PATH=”dir/example.tar.gz” $> FILE=”example.tar.gz” $> dirname $FILE_PATH dir $> dirname $FILE . $> basename $FILE_PATH example.tar.gz $> basename $FILE example.tar.gz # ——————————- # dir/example.tar(.gz) : $> echo “${FILE_PATH%.*}” dir/example.tar # dir/example(.tar(.gz)) : $> echo “${FILE_PATH%%.*}” dir/example # example.tar(.gz) : $> echo “${FILE%.*}” example.tar # example(.tar(.gz)) :…

Read More