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

前端 未结 4 1667
误落风尘
误落风尘 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:51

    The . ./import.sh "sources" the script, where as simply ./import.sh just executes it.

    The former allows you to modify the current environment, where the later will only affect the environment within the child execution.

    The former is also equivalent to (though mostly Bash-specific):

    source ./import.sh
    

    help source yields:

    source: source filename [arguments]

    Execute commands from a file in the current shell.

    Read and execute commands from FILENAME in the current shell. The entries in $PATH are used to find the directory containing FILENAME. If any ARGUMENTS are supplied, they become the positional parameters when FILENAME is executed.

    Exit Status: Returns the status of the last command executed in FILENAME; fails if FILENAME cannot be read.

提交回复
热议问题