Linux / UNIX: Command For Executing a Shell Script

To execute a shell script in Linux or UNIX, you can use the following command in the terminal:

$ sh script.sh

Replace “script.sh” with the name of your shell script.

Alternatively, you can make the script executable by changing its permissions and then simply run it as an executable file:

$ chmod +x script.sh
$ ./script.sh

The script will then be executed with the current shell, and any commands within the script will be executed in sequence.

Note: The exact syntax of the command to execute a shell script may vary depending on the shell you are using. For example, in the bash shell, you can use the following command to execute a script:

$ bash script.sh

or simply:

$ ./script.sh

Leave a Comment