Oneliner bash built-in (doesn't work for repetition):
DIR=/dir/to/remove PATH=${PATH/${PATH/#$DIR:*/$DIR:}/}${PATH/${PATH/*:$DIR*/:$DIR}/} - Uses recursive shell parameter expansion to remove colon before or after removed directory
- Pattern has two halves. One half is always empty, other provide reduced path.
- Removes just one instance of $DIR from $PATH