0

Both of two lines below seems to execute my_script. What's the difference between the two processes?

$ bash my_script
$ source my_script

marked as duplicate by muru, Stephen Kitt bash Jun 16 at 8:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

A major different is that bash runs in a subprocess, while source is as if you are running the content:

$ cat my_script
echo $$
$ bash my_script
85183
$ source my_script
1581
$ echo $$
1581
  • So is the line $ bash my_script the same as simply calling the script name $ my_script? – Jack Chen Jun 16 at 10:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.