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?

Mehran Goudarzi
  • 83
  • 1
  • 1
  • 9

2 Answers2

2

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
  • 19,979
  • 21
  • 92
  • 137
2
source path.sh

add this step is fine.

bbotte
  • 168
  • 5