Differences in Serveral Executable Commands in Linux
In Linux, there are several commands to execute shell scripts such as bash
, source
, sh
, ./
. So, what are the differences of them?
source
1 | source a.sh |
Execute the specified shell script in current bash, and the executable authority of this script is unneccesary. Besides, .
equals source
:
1 | . a.sh |
bash/sh
1 | sh a.sh |
Execute the specified shell script in the subshell, and the executable authority of this script is also unneccesary.
./
1 | ./ a.sh |
Execute the specified shell script in the subshell, and the executable authority of this script is also neccesary so that chmod u+x .
can be used to
change the authority of the scirpt.
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment