Skip to main content
Avoid the trailing ":". pathmerge typo.
Source Link
Stephen Kitt
  • 483.6k
  • 60
  • 1.2k
  • 1.4k

I've seen people clean up duplicates from their PATH variable using awk and something like this:

PATH=$(echoprintf "%s" "$PATH" | awk -v RS=':' -v'!a[$1]++ ORS=":"{ if (NR > 1) printf RS; printf $1 }'!a[$1]++') 

You could try adding that to your own bashrc and make sure you source the other files somewhere before running that.

An alternative would be to use the pathmeargepathmerge utility.

As for your speed problem, this will not affect the startup time of the shell in any significant way but it may save some time doing tab completion for commands, especially when the command is not found in the path and it does repeated searches through the same folders looking for it.

A note on security: You should really heed Gilles' warnings about security here. By sourcing a file owned by another user you are giving a free pass to those users to execute their own code as your user every time you start a shell. If you don't trust those users with your password, you shouldn't be sourcing their shell files.

I've seen people clean up duplicates from their PATH variable using awk and something like this:

PATH=$(echo "$PATH" | awk -v RS=':' -v ORS=":" '!a[$1]++') 

You could try adding that to your own bashrc and make sure you source the other files somewhere before running that.

An alternative would be to use the pathmearge utility.

As for your speed problem, this will not affect the startup time of the shell in any significant way but it may save some time doing tab completion for commands, especially when the command is not found in the path and it does repeated searches through the same folders looking for it.

A note on security: You should really heed Gilles' warnings about security here. By sourcing a file owned by another user you are giving a free pass to those users to execute their own code as your user every time you start a shell. If you don't trust those users with your password, you shouldn't be sourcing their shell files.

I've seen people clean up duplicates from their PATH variable using awk and something like this:

PATH=$(printf "%s" "$PATH" | awk -v RS=':' '!a[$1]++ { if (NR > 1) printf RS; printf $1 }') 

You could try adding that to your own bashrc and make sure you source the other files somewhere before running that.

An alternative would be to use the pathmerge utility.

As for your speed problem, this will not affect the startup time of the shell in any significant way but it may save some time doing tab completion for commands, especially when the command is not found in the path and it does repeated searches through the same folders looking for it.

A note on security: You should really heed Gilles' warnings about security here. By sourcing a file owned by another user you are giving a free pass to those users to execute their own code as your user every time you start a shell. If you don't trust those users with your password, you shouldn't be sourcing their shell files.

replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

I've seen people clean up duplicates from their PATH variable using awk and something like this:

PATH=$(echo "$PATH" | awk -v RS=':' -v ORS=":" '!a[$1]++') 

You could try adding that to your own bashrc and make sure you source the other files somewhere before running that.

An alternative would be to use the pathmearge utility.

As for your speed problem, this will not affect the startup time of the shell in any significant way but it may save some time doing tab completion for commands, especially when the command is not found in the path and it does repeated searches through the same folders looking for it.

A note on security: You should really heed Gilles' warningsGilles' warnings about security here. By sourcing a file owned by another user you are giving a free pass to those users to execute their own code as your user every time you start a shell. If you don't trust those users with your password, you shouldn't be sourcing their shell files.

I've seen people clean up duplicates from their PATH variable using awk and something like this:

PATH=$(echo "$PATH" | awk -v RS=':' -v ORS=":" '!a[$1]++') 

You could try adding that to your own bashrc and make sure you source the other files somewhere before running that.

An alternative would be to use the pathmearge utility.

As for your speed problem, this will not affect the startup time of the shell in any significant way but it may save some time doing tab completion for commands, especially when the command is not found in the path and it does repeated searches through the same folders looking for it.

A note on security: You should really heed Gilles' warnings about security here. By sourcing a file owned by another user you are giving a free pass to those users to execute their own code as your user every time you start a shell. If you don't trust those users with your password, you shouldn't be sourcing their shell files.

I've seen people clean up duplicates from their PATH variable using awk and something like this:

PATH=$(echo "$PATH" | awk -v RS=':' -v ORS=":" '!a[$1]++') 

You could try adding that to your own bashrc and make sure you source the other files somewhere before running that.

An alternative would be to use the pathmearge utility.

As for your speed problem, this will not affect the startup time of the shell in any significant way but it may save some time doing tab completion for commands, especially when the command is not found in the path and it does repeated searches through the same folders looking for it.

A note on security: You should really heed Gilles' warnings about security here. By sourcing a file owned by another user you are giving a free pass to those users to execute their own code as your user every time you start a shell. If you don't trust those users with your password, you shouldn't be sourcing their shell files.

grammar, spelling fixes
Source Link
muru
  • 78.3k
  • 16
  • 214
  • 320

I've seen people clean up duplicates from their PATH variable using awk and something like this:

PATH=$(echo "$PATH" | awk -v RS=':' -v ORS=":" '!a[$1]++') 

You could try adding that to your own bashrc and make sure you source the other files somewhere before running that.

AndAn alternative would be to use thisthe pathmearge utility.

As for your speed problem, this will not affect the startup time of the shell in any significant way but it may save some time doing tab completion for commands, especially when the command is not found in the path and it does repeated searches through the same folders looking for it.

A note on security: You should really headheed Gilles' warnings about security here. By sourcing a file owned by another user you are giving a free pass to those users to execute their own code as your user every time you start a shell. ifIf you don't trust those users with your password, you shouldn't be sourcing their shell files.

I've seen people clean up duplicates from their PATH variable using awk and something like this:

PATH=$(echo "$PATH" | awk -v RS=':' -v ORS=":" '!a[$1]++') 

You could try adding that to your own bashrc and make sure you source the other files somewhere before running that.

And alternative would be to use this pathmearge utility.

As for your speed problem, this will not affect the startup time of the shell in any significant way but it may save some time doing tab completion for commands, especially when the command is not found in the path and it does repeated searches through the same folders looking for it.

A note on security: You should really head Gilles' warnings about security here. By sourcing a file owned by another user you are giving a free pass to those users to execute their own code as your user every time you start a shell. if you don't trust those users with your password, you shouldn't be sourcing their shell files.

I've seen people clean up duplicates from their PATH variable using awk and something like this:

PATH=$(echo "$PATH" | awk -v RS=':' -v ORS=":" '!a[$1]++') 

You could try adding that to your own bashrc and make sure you source the other files somewhere before running that.

An alternative would be to use the pathmearge utility.

As for your speed problem, this will not affect the startup time of the shell in any significant way but it may save some time doing tab completion for commands, especially when the command is not found in the path and it does repeated searches through the same folders looking for it.

A note on security: You should really heed Gilles' warnings about security here. By sourcing a file owned by another user you are giving a free pass to those users to execute their own code as your user every time you start a shell. If you don't trust those users with your password, you shouldn't be sourcing their shell files.

added 734 characters in body
Source Link
Caleb
  • 72k
  • 19
  • 203
  • 234
Loading
Source Link
Caleb
  • 72k
  • 19
  • 203
  • 234
Loading