#!/usr/bin/env bash file="archive.tar.gz" # % removes the shortest trailing match, %% the longest echo "${file%.*}" echo "${file%%.*}"
${s%pattern} removes a trailing match