Search for Ebooks

Programming the UNIX/linux Shell

By Claude Cantin

Bourne - C shell comparisons
A Bourne Shell Script is a file containing a series of Bourne Shell commands, as well as control structures such as if statements, while loops, etc. Parameters can be passed to the script and data can be read from the keyboard.

Bourne shell scripts are usually Algol-66 look-alikes, whereas C shell scripts look more like C program constructs.

The C shell is slower to start execution (as it looks in the .cshrc file EVERY TIME it is called) and produces a hash table of all paths for faster execution. The Bourne shell is slower, but starts executing immediately.

For that reason, short scripts are executed much faster in the Bourne Shell than the C shell (this is noticeable for small SLOW machines; with systems running at 30 to 130 MIPS/CPU, the difference in speed is almost insignificant). Large scripts should most likely be written in a compiled language--preferably C--because compiled code executes much faster than interpreted code.

Many features of the Bourne shell are also found in the C shell. Parameters are interpreted in the same way. Variable assignments are very similar. UNIX commands are exactly the same. Control structures and comparisons differ the most.