Skip to content
Advertisement

What is the difference between “source script.sh” and “./script.sh”?

What is the difference between source <script> and ./<script>?

Advertisement

Answer

source script.sh runs the script within the current process, thus all variable assignments are preserved as variables even after the script finishes (and don’t have to be explicitly export‘d).

./script.sh just runs the script in a subprocess, and any variables which are assigned disappear after the script is done.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement