4 Ways to Execute script



Script is to be made executable

From the login shell, a new shell is loaded into memory

which reads the commands from the script file, where as the login

shell is on hold

Note : The variables set in the login shell and variables

in the new shell are different and not retained.


#sh script1

Similar to above, but the scripts is not required to be made executable


#. script1

The commands in the scripts are executed by current shell

Variable set in the script are retained as it is executed b current shell


#exec script1

execute the script and exit the session as soon as the

script execution is complete