0

I want to add PATH on Linux Ubuntu 18.04 from file path.sh , my file include :

 #!/bin/bash
 export PATH="$PATH:/root/.local/bin"

chmod+x path.sh , but when i run it ./path.sh Path not add when i type echo $PATH .

but when i type in terminal export PATH="$PATH:/root/.local/bin" it added to my PATH .

Am I miss something on my file?

2 Answers2

1

Let's consult man bash:

export [-fn] [name[=word]] ...
export -p
       The  supplied names are marked for automatic export to the envi-
       ronment of subsequently executed commands.

Note "subsequently executed commands", therefore the effect of your script ends, once the script ends.

Micha Wiedenmann
  • 18,825
  • 20
  • 87
  • 132
0
source path.sh

add this step is fine.

bbotte
  • 98
  • 5