4 Ways to Execute script

1)

#./script1

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.

2)

#sh script1 

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

3) 

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

4)

#exec script1

execute the script and exit the session as soon as the
script execution is complete

Comments