Here is a simple example of creating and running (executing) a shell script. This script will display the numbers from 1 to 10.
Creating the script:
- With any text editor (Gedit for Gnome, Kate for KDE, nano):
#/bin/bash for ((i = 1; i <= 10; i ++)) do echo $i done - Save it as myscript.sh.
Setting the execution rights:
Open a console, go to the directory where the script was saved and type:
chmod +x myscript.sh
Running the script:
- In the console type:
./script.sh
or
sh script.sh
The result should be like this:
1 2 3 4 5 6 7 8 9 10

Pingback: Understanding file permissions and ownership on Linux | Cristian Radulescu