| LINKS |
|
COMPUTING NEWS |





An Introduction to Shell Scripts.
The Linux terminal is one of the things that gives a power and added flexibility to the Linux user. It has many functions, from running your programs, copy files, create directories, even read email. Many things are available to us from this small window.All scripts shown here have been written in a text editor (gedit) and the input / output you see is copied directly as seen. The system is Debian 'Lenny' and we are using the bourne shell.
Here are a couple of things you can input into the terminal and see the response immediately.
paul@linuxfx:~$ echo $PATH
This will bring a response similar to this:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
This is just an informative line, scripts themselves have to be written in a text editor - vi, emacs or the simple gedit will suffice.
Before continuing, we can create a new directory to store the scripts:
paul@linuxfx:~$ mkdir bin
In a text editor write the following:
=========================================================
#!/bin/bash
# My first script
echo "Hello World!"
=========================================================
Save the file in your new scripts folder as hello.sh
Back in the terminal change to the scripts directory:
paul@linuxfx:~$ cd /home/paul/bin
This will alter the path you are now in, so you can now make the file executable from within the shell:
paul@linuxfx:~/bin$ chmod 755 hello.sh
We shall now run the script with the following:
paul@linuxfx:~/bin$ ./hello.sh
....here is your first shell script:
Hello World!
>>>>>>>Next - Worthwhile Shell / Linux Commands.


