Question

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.

Was it helpful?

Solution

I use this oneliner, but it depends on gawk.

PATH=$(echo $PATH|tr ":" "\n"|gawk '!($0 in a) { a[$0];print}'|paste -sd: - )
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top