Unix Shells in a Nutshell

A Shell is a command line interpreter. As command interpreters, they process commands you enter on the command line in response to a prompt. We can also use the shell as a programming language where it processes commands stored in files called shell scripts. Like other languages, shells have variables and control flow commands (for example, for loops and if statements). 

When we use a shell as a command interpreter, we can customize the environment we are working in. We can make shell prompt display the name of the working directory, create a function or alias for cp that keeps it from overwriting certain kinds of files and so on. We can also write shell scripts that do our bidding, from a one-line script that stores a long, complex command to a longer script that runs a set of reports, prints them, and mails you a reminder when the job is done. 

Lets see which are the various shells available in UNIX or LINUX for us to work upon.

Bourne Shell(sh)
Because of its long and successful history, the original Bourne Shell has been used to write many of the shell scripts that help manage UNIX systems. On UNIX systems the original Bourne Shell is named sh. On Linux systems sh is a symbolic link to bash ensuring that scripts that require the presence of the Bourne Shell still run. 

Bourne Again Shell(bash)
Bash is a Unix shell written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell (sh). Released in 1989, it has been distributed widely as the shell for the GNU operating system and as the default shell on Linux and Mac OS X. Bash can also read commands from a file, called a script. Like all Unix shells, it supports filename wildcarding, piping, command substitution, variables and control structures for condition-testing and iteration. The keywords, syntax and other basic features of the language were all copied from sh. 

Korn Shell(ksh)
KornShell (ksh) is a Unix shell which was developed by David Korn at Bell Labs in the early 1980s and announced at USENIX on July 14, 1983. KornShell is backward-compatible with the Bourne shell and includes many features of the C shell, inspired by the requests of Bell Labs users. KornShell complies with POSIX.2, Shell and Utilities, Command Interpreter (IEEE Std 1003.2-1992.) Major differences between KornShell and the traditional Bourne shell include:
  • Job control, command aliasing, and command history designed after the corresponding C shell features.
  • Three WYSIWYG-style line editing modes designed to make an interactive shell session behave like vi, Emacs, or XEmacs;
  • Associative arrays and built-in floating point arithmetic operations (only available in the ksh93 version of KornShell.)

Z shell(zsh)
The Z shell (zsh) is a Unix shell that can be used as an interactive login shell and as a powerful command interpreter for shell scripting. Zsh can be thought of as an extended Bourne shell with a large number of improvements, including some features of bash, ksh, and tcsh.

  • Programmable command-line completion that can help the user type both options and arguments for most used commands, with out-of-the-box support for several hundred commands
  • Sharing of command history among all running shells
  • Extended file globbing allows file specification without needing to run an external program such as find
  • Improved variable/array handling
  • Editing of multi-line commands in a single buffer
  • Spelling correction
  • Various compatibility modes, e.g. zsh can pretend to be a Bourne shell when run as /bin/sh
  • Themeable prompts, including the ability to put prompt information on the right side of the screen and have it auto-hide when typing a long command
  • Loadable modules, providing among other things: full TCP and Unix domain socket controls, an FTP client, and extended math functions
  • Fully customizable
Tee Shell(tsch)
tcsh  is a Unix shell based  on and compatible with the C shell (csh). It is essentially the  C shell with programmable  command line completion, command-line editing, and a few other features.


  • Command history
  • The built-in history command displays the previously-entered commands
  • Command line editing
  • Auto-completion of file names and variables at the command line
  • Alias argument selectors; the ability to define an alias to take arguments supplied to it and apply them to the commands that it refers to. Tcsh is the only shell that provides this feature.
  • Wildcard matching
  • Job control
  • The built-in where command. Works like the which command but shows all locations of the target command in the directories specified in $PATH rather than only the one that will be used.

The C Shell(csh)
The C shell (csh or the improved version, tcsh, on most machines) is a Unix shell  that was created by Bill Joy while a graduate student at University of California,  Berkeley in the late 1970s. It has been distributed widely, beginning with the 2BSD release of the BSD Unix system that Joy began distributing in 1978. Other early contributors to the ideas or the code were Michael Ubell, Eric Allman, Mike O'Brien and Jim Kulp.

The C shell is a command processor typically run in a text window, allowing the user to type commands. The C shell can also read commands from a file, called a script. Like all Unix shells,  it supports filename wildcarding, piping, here documents,  command substitution, variables and control structures for 
condition-testing and iteration. What differentiated the C shell from others, especially in the 1980s, were its interactive features and overall style.  Its new features made it easier and faster to use. The overall style of the language looked more like C and was seen as more readable.

These were the Shells available in Unix, other shells also exist but i don't find them relevant enough to be discussed here as above the the main and the important ones.

About Posix Standard
The POSIX (the Portable Operating System Interface) family of related standards is being developed by PASC (IEEE's Portable Application Standards Committee) A comprehensive FAQ on POSIX, including many links, appears at www.opengroup.org/austin/papers/posix_faq.htmlPOSIX standard 1003.2 describes shell functionality. The Bourne Again Shell provides the features that match the requirements of this POSIX standard. Efforts are under way to make the Bourne Again Shell fully comply with the POSIX standard. In the meantime, if you invoke bash with the – –posix option, the behavior of the Bourne Again Shell will more closely match the POSIX requirements.

You May Also Like This :

No comments: