Recent bash versions (>= 4) also of associative arrays, i.e. you can also use a bash 'one liner' for it:
PATH=$(IFS=:; set -f; declare -A a; NR=0; for i in $PATH; do NR=$((NR+1)); \
if [ \! ${a[$i]+_} ]; then if [ $NR -gt 1 ]; then echo -n ':'; fi; \
echo -n $i; a[$i]=1; fi; done)
where:
IFSchanges the input field separator to:declare -Adeclares an associative array${a[$i]+_}is a parameter expansion meaning:_is substituted if and only ifa[$i]is set. This is similar to${parameter:+word}which also tests for not-null. Thus, in the following evaluation of the conditional, the expression_(i.e. a single character string) evaluates to true (this is equivalent to-n _) - while an empty expression evaluates to false.