Here's a sleek one:
echo -n $PATH | awk -v RS=: -v ORS=: '!arr[$0]++'
Longer (to see how it works):
echo -n $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=`echo -n $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 screwed.
some credit to:
- [this blog][1]
- [this thread][2]
[1]: http://unstableme.blogspot.com/2008/03/remove-duplicates-without-sorting-file.html
[2]: http://dbaspot.com/shell/365450-uniq-without-sort-guru-needed.html