Portable Shell Programming
Using the Bash Shell and Korn Shell

Note: This book has not been published yet. It contains information from my previous book, Portable Shell Programming: An Extensive Collection of Bourne Shell Examples. The copyright for that book is owned by the Hewlett-Packard Company, and unfortunately, they are no longer involved with publishing technical books and will not give me permission to use information from that book. Therefore, as it now stands, this book is not likely to ever be published.

Table of Contents (PDF file)

The first version of this book was written several years ago.  At that time, it was called Portable Shell Programming: An Extensive Collection of Bourne Shell Examples.  That book provided examples of shell scripts that would run on any UNIX system.  This meant that the examples were constrained to only use functionality that was available on all versions of UNIX.  In particular, the examples in that book were intended for use with the Bourne shell.

Since that time, the functionality of the shell and most of the commands and utilities have been standardized in the POSIX standard.  All the major implementations of UNIX and Linux conform to the POSIX standard; therefore, applications can now use the functionality defined in the POSIX standard as a baseline for functionality that is available on all systems.

The examples in this book are written for the Bash shell and the Korn shell.  These are the most commonly used shells and they both conform to the POSIX standard.  Both of these shells also have additional capabilities that are not defined in the POSIX standard, but for the most part, the examples in this book stick to the capabilities defined in the POSIX standard.  This allows the examples in this book to work with both the Bash shell and the Korn shell and to be portable to a wide variety of systems.

What is the Bash Shell?

The Bash shell, which stands for the "Bourne Again SHell," is a shell that was originally developed by Brian Fox of the Free Software Foundation, and it is currently maintained by Chet Ramey of Case Western Reserve University.

The Bash shell is a POSIX compatible shell, but it also has several additional features. The Bash shell is relatively new, so it has been able to incorporate the best features from other shells in addition to some new features of its own.

What is the Korn Shell?

The Korn shell was developed by David Korn at Bell Laboratories.  The Korn shell is forward compatible with the Bourne shell, but it has many additional features that make the Korn shell more suitable for interactive use than the Bourne shell.  The 1988 version of the Korn shell was a significant source of the functionality that was used to establish the POSIX standard, but since it preceded the standard, the 1988 version of the Korn shell is not POSIX compliant.

The 1993 version of the Korn shell is a major rewrite from the 1988 version.  The 1993 version of the Korn shell is POSIX compliant, it has many new features that make it a better scripting language, and it is has improved performance.

Examples from the Book

You can click the links below to get any of the examples from the book. The tar file contains all of the examples.

Shell Commands

Shell Functions