I am reading an article on executing bash shell scripts.
Method 1: Create a directory for your shell scripts and add the directory to the contents of the PATH variable, so that you can execute the script as shown below. When this executes, the variables, functions and aliases created in this subshell are only known to the particular bash session of that subshell. When that shell exits and the parent regains control, everything is cleaned up and all changes to the state of the shell made by the script, are forgotten.
Method 2: A script can also explicitly be executed by a given shell. The specified shell will start as a subshell of your current shell and execute the script.
$ sh script_name.sh
Method 3: If you don't want to start a new shell but execute the script in the current shell, you source it:
I really don't understand the benefits and disadvantages of each of these methods. Can anyone clarify?