Skip to main content
3 of 3
properly handle paths with spaces
Varp
  • 11
  • 2

The right way of removing duplicates suggested by @ghm1014 and @rush (in the comment) using sort:

PATH=`echo -e ${PATH//:/'\n'} | awk '{printf("%d|%s\n", NR, $0)}' | sort -t '|' -k 2 -u | sort -t '|' -k 1 -g | cut -f2 -d'|'`; export PATH=${PATH//[$'\n']/:}
Varp
  • 11
  • 2