LinuxFocus.org: Shell Programming
Sep 30, 2001, 21:45 (9 Talkback[s])
(Other stories by Guido Socher)
"Even though there are various graphical interfaces
available for Linux the shell still is a very neat tool. The shell
is not just a collection of commands but a really good programming
language.You can automate a lot of tasks with it, the shell is very
good for system administration tasks, you can very quickly try out
if your ideas work which makes it very useful for simple
prototyping and it is very useful for small utilities that perform
some relatively simple tasks where efficiency is less important
than ease of configuration, maintenance and portability. So let's
see now how it works:
There are a lot of different shells available for Linux but
usually the bash (bourne again shell) is used for shell programming
as it is available for free and is easy to use. So all the scripts
we will write in this article use the bash (but will most of the
time also run with its older sister, the bourne shell). For writing
our shell programs we use any kind of text editor, e.g. nedit,
kedit, emacs, vi...as with other programming languages. The program
must start with the following line (it must be the first line in
the file):
#!/bin/sh
The #! characters tell the system that the first argument that
follows on the line is the program to be used to execute this file.
In this case /bin/sh is shell we use. When you have written your
script and saved it you have to make it executable to be able to
use it. To make a script executable type chmod +x filename Then you
can start your script by typing: ./filename"
Complete Story
Related Stories:
- UNIXReview.com: The Shell Corner [Inaugural edition... win money for shell scripts](Dec 17, 2000)
- Canada Computes: Learning The Bash Shell [Book Review](Dec 16, 2000)
- FreeOS.com: Linux shell script tutorial(Oct 10, 2000)
- NorthernJourney.com: Linux for Newbies: Shell Concepts(Sep 18, 2000)
- Linux Journal: LINUX & UNIX Shell Programming [Book Review](Jun 25, 2000)
- Linux.com: Shell Skills, Part 1: Working with Files(Jun 23, 2000)
- LinuxPapers.org: First Steps With GNU/Linux(Apr 02, 2000)
- TheLinuxGurus.org: Linux Programming By Example [Book Review](Jan 31, 2000)
- TheLinuxGurus.org: Incredibly Simple Shell Programming(Jan 20, 2000)