Here's a sleek one:
printf %s "$PATH" | awk -v RS=: -v ORS=: '!arr[$0]++' Longer (to see how it works):
printf %s "$PATH" | awk -v RS=: -v ORS=: '{ if (!arr[$0]++) { print $0 } }' Ok, since you're new to linux, here is how to actually set PATH without a trailing ":"
PATH=`printf %s "$PATH" | awk -v RS=: '{ if (!arr[$0]++) {printf("%s%s",!ln++?"":":",$0)}}'` btw make sure to NOT have directories containing ":" in your PATH, otherwise it is gonna be screwedmessed up.
some credit to: