Shell Programming  «Prev 

Shell Scripting

The UNIX command-line interface has been criticized for complexity and a steep learning curve, but no one disputes that it is one of the most flexible and programmable user interfaces ever developed. The core of the UNIX command- lineinterface is the shell, a program that interprets and executes user commands. The shell can take commands from a keyboard or stored in files; the syntax and commands are the same either way.
A file containing shell commands is called a shell script. Many systems offer shells that are arguably programmable; the UNIX shell environment is actually good at it. As a result, thousands upon thousands of programs have been implemented as shell scripts. This book treats the shell as a serious programming language and introduces the practice of portable shell scripting the development of scripts that can be expected to run on a variety of host systems or even different shells on the same system. What systems, you ask?
Anything that looks reasonably like UNIX, whether it is Solaris, Linux, NetBSD, OS X, or even environments such as Cygwin, which provides UNIX- like behavior under Windows. Do not mistake this for an exhaustive list.
Not everyone thinks highly of portability as a goal. Linus Torvalds once said, "Portability is for people who cannot write new programs."
As a great fan of portability, I am inclined to nearly agree. I prefer, "Portability is for people who are too busy to write new programs."
Users often imagine that portability is a gigantic nightmare requiring a huge amount of additional work; however, in the vast majority of cases, writing portable code takes little extra time, and pays for itself quickly. Portability usually does not mean writing completely different versions of the same program for every system; rather, it means writing a single version that is correct everywhere.

Which Unix Shells are available?

Stephen Bourne develops the Bourne shell

Bill Joy creates the C shell to add interactive features.

David Korn adds interactive features to the Bourne shell to create the Korn shell.

The C shell is refined in the TENEX/TOPS C shell.

The Bourne shell is revised as the Bourne again shell.

The Z shell and public domain Korn shells build upon their predecessors.