How to remove characters from the end of a string in BASH

BASH has a builtin method of removing characters from the end of a string variable. The example below shows how to remove a specific extension from a file name string:

#!/bin/bash
FILE="hello.txt"
EXT="txt"
echo "${FILE%.$EXT}"

Last updated: 06/12/2013