Extraire le chemin, le nom et l’extension d’un fichier en bash
fullpath="$@" filename="${fullpath##*/}" # Strip longest match of */ from start dir="${fullpath:0:${#fullpath} - ${#filename}}" # Substring from 0 thru pos of filename base="${filename%.[^.]*}" # Strip shortest match of . plus at least one non-dot char from end ext="${filename:${#base} + 1}" echo "filename : $filename" echo "dir : $dir" echo "base : $base" echo "ext : $ext"