There are many ways how to execute a script, the first one is execute script by specifying the interpreter:
For debugging use option "-x" to see what is being done.
bash -x script.sh
As interpreter you can use sh, ksh, csh, bash etc.
If you want to execute script without specifying interpreter, you need to set execute (+x) permission:
chmod +x script.sh
Then you can execute script following way:
Another way how to run script:
The script doesn't need execute permission in this example. If script makes any changes to environment, it will be visible after running script, because commands in script are executed in current shell.
Was this information helpful to you? You have the power to keep it alive.
Each donated € will be spent on running and expanding this page about UNIX Shell.
We prepared for you video course Marian's BASH Video Training: Mastering Unix Shell, if you would like to get much more information.
Thank you. Marian Knezek