Shell (almost) regexp variable substitution
Tuesday, July 12th, 2005${variable#pattern}
If the pattern matches the beginning of the variable’s value, delete the shortest part that matches and return the rest.
${variable##pattern}
If the pattern matches the beginning of the variable’s value, delete the longest part that matches and return the rest.
${variable%pattern}
If the pattern matches the end of the variable’s value, delete the shortest part that matches and return the rest.
${variable%%pattern}
If the pattern matches the end of the variable’s value, delete the longest part that matches and return the rest.