Monday, December 27, 2010

How to execute a scirpt in Linux

A shell script can be executed using the following syntax
chmod +x script.sh
./script.sh

You can also run the script directly without setting the script execute permission
bash script.sh
or
source script.sh
or
. script.sh

In the last example we are using . (dot) or source command which reads and executes commands from filename in the current shell.
When a script is executed using either the bash command or the source (.) command, you don't have to set execute permission on script.

reference: http://www.cyberciti.biz

No comments:

Post a Comment