2

Similar question to How to keep from duplicating path variable in csh. But I don't use csh.

PATH=${SOMETHING}:${PATH}

How do I remove duplicates from PATH.

Community
  • 1
  • 1
Sanjaya R
  • 6,246
  • 2
  • 17
  • 19

1 Answers1

3

I use this oneliner, but it depends on gawk.

PATH=$(echo $PATH|tr ":" "\n"|gawk '!($0 in a) { a[$0];print}'|paste -sd: - )
Sanjaya R
  • 6,246
  • 2
  • 17
  • 19