Shell programming was not something I wanted to do from the start,
it kind of crept up on me over the years. You know how it is,
you do something regular enough that it gets boring and you try
to find short cuts. Well after my first UNIX training course I
went back to the office and started to look at the support requirements
and it soon became obvious that to do a good job something had
to be done regarding the overload of administration on a detailed
level as the system grew. Initially my scripts were small and
dedicated , and to do the same thing for
several users I just
copied the script into their home directory and edited a few lines
and off it went. After a few weeks, I spotted the error of my
ways and created a directory for scripts that could be shared.
I put the directory into everyone's path and started moving scripts
into this central place. By editing the scripts and putting in
variables, instead of hard coded values, I found I could make
them generic enough for anybody to use, as long as the user's
environment contained enough background information for the script
to pick up and use.
A few months down the line and I saw another opportunity as I
was aware there was a lot of common code in most of these scripts.
Why keep copying all this code when I could call it from another
file? Two things sprang to mind initially, one was the .profile,
which I was already using to store users environment variables,
the other was functions, which I had seen one of my friends use
in a long script suite. I dug out the man pages for the shells
and spent the next few days looking at sh, csh,
and ksh in detail, trying out short test scripts to make
sure I understood what was written. I had a look in my local book
store for books on shell programming generally. Alas the only
books available were very basic and covered what I had already
What I did pick up at this time was that there was a
general disliking for the C Shell in most books I found. It was
pointed out on numerous occasions how many bugs there were. I
must admit, even the man pages themselves highlight several pages
of bugs at the back. I was also aware that to fully support a
networked system there were several files you had to be able to
edit and fix when things changed. These are the basic system set
up files and spool daemons etc. All of these files are of course
written using the Bourne Shell. You become quite good at the Bourne
Shell when you set up printer drivers for a networked drawing
archival system with distributed printers and plotters.
What I started to see here was a language that was very succinct
- terse, but to the point. It had few bugs - certainly no one
remarked on them. It was also very portable in that all UNIX systems
support it and make use of it exclusively for low level set up
scripts and installation suites. I found this a bit of a nuisance
because I was a C Shell programmer and I liked my cosy environment!
But when I saw these functions used, I started to see real benefits
- C Shell does not have functions.
I converted a few scripts,
it's not too difficult - just a few key word changes, the if
syntax, etc. Then I put in a few functions to replace some common code.
Well, look at that! The script is now only half the size and
still does the same thing! What's more, if I change this function,
all the scripts that call it are immediately updated too! This
is neat! The rest, as they say, is history.
Shortcuts to Code Examples and Zipped Word Docs
- Called each time you start a Bourne or Korn script. Calls all
the other required profiles in sequence. Don't forget to add
new profiles at the end of this list.
- Called from .profile to load each of the function (or subroutine)
unit files (strings, dates, utils, etc) at each invocation
- Contains all the functions dealing with date formats and date
transformations and manipulations.
- Contains all the string, word, and character manipulation type
- Contains all the file creation and deletion type functions which
are used to administer temporary files and logfiles.
- Contains all the database access utilities both for SQL*Net 1 and
SQL*Net 2 versions of the Oracle ™ network access
- Contains functions relating to file transfer and mail utilities.
- Contains function that don't fit into the other categories. This
group generally get broken down when the list gets too long.
- Contains My Shell Scripting Guide in Microsoft Word 6.0 format
structured as a master document with 18 sections.
This list will be updated from time to time as new functions become
available. I will endevour to keep the most up to date stuff in the
file on a monthly basis. However, code which has not yet been integrated
into the zip file can be found below as plain text.