• Uncategorized

About linux : What-is-the-difference-between-source-scriptsh-and-scriptsh

Question Detail

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

Question 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.

source script will change your current environment, ./script will not.

(EDIT: script has to be executable to use ./)

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.