How to create a simple shell script
November 15, 2007 – 17:56Here 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):
1 2 3 4 5
#/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.shRunning the script:
- In the console type:
./script.shor
sh script.shThe result should be like this:
1 2 3 4 5 6 7 8 9 10
Tags: linux script, Programming, shell script
1 Trackback(s)