What is the difference between these two commands which are used to run shell script?

前端 未结 4 1673
误落风尘
误落风尘 2021-01-25 04:16

Here I have one script which exporting some necessary path in Linux. After running this script I have to run some other scripts.

I have two scripts

1 imp         


        
4条回答
  •  逝去的感伤
    2021-01-25 04:38

    ./import.sh runs the script as a normal script - that is, in a subshell. That means it can't affect your current shell in any way. The paths it's supposed to import won't get set up in your current shell.

    The extra ., which is equivalent to source, runs the script in the context of your current shell - meaning it can modify environment variables, etc. (like the paths you're trying to set up) in the current shell. From the bash man page:

    . filename [arguments]
    source filename [arguments]
    Read and execute commands from filename in the current shell environment and return the exit status of the last command executed from filename.

提交回复
热议问题