I am trying to use 'source ~/.bash_profile' command from a shell script. But this doesn't work. My script is like this: test.sh
#!/bin/bash
source ~/.bash_profile
I use many ways to run the script ./test.sh
, bash test.sh
and sh test.sh
. if run with . /test.sh
it is work. This is the running the script? This is the right way to run the installation script?
btw I also test by changing script with . ~/.bash_profile
, bash ~/.bash_profile
, sh ~/.bash_profile
, bash -c '~/.bash_profile'
.
What is the 'source' problem in shell script. Please explain me what is the right way? How can i source .bash_profile in the script. Thank to everyone!!