Saturday, February 15, 2020

Separating filename from extension in bash

If we want to separate filename from extension in bash this is a neat and useful trick:


filename=$(basename -- "$fullfile")
extension="${filename##*.}"
filename="${filename%.*}"