Linux (28) Python (13) Raspberry Pi (5) Bugs (3) Install (3) C (2) Brainf**k (1) HTML (1) Maths (1) Sorts (1)

Monday, 5 December 2016

Creating a excutable shell script

When writing shell scripts you can use .sh file extension and run using the sh command.

You can make your shell script executable and run using ./

To make it like this we need to do 2 things:
Change the file permissions
Define the interpreter/shell we will be using in the script.

Changing the file permissions:
Run the command:
chmod 0755
This will allow all users to run the script

To only allow the current user to run the script run:
chmod 0700

Defining the shell within the script:
Add the following line to the start of the script
Depending on which one you are using.

Now you can run your script by typing

No comments:

Post a comment