History
The original Bourne shell distributed with V7 Unix in 1979 became the standard shell for writing shell scripts. The Bourne shell is still found in /bin/sh on many commercial Unix systems . It has not changed that much since its initial release, although it has seen modest enhancements over the years. The most notable new features added were the CDPATH
variable and a built-in test command with System III (circa 1980), command hashing and shell functions for System V Release 2 (circa 1984), and the addition of job control features for System V Release 4 (1989).
Because the Berkeley C shell ( csh ) offered features that were more pleasant for interactive use, such as command history and job control, for a long time the standard practice in the Unix world was to use the Bourne shell for programming and the C shell for daily use. David Korn at Bell Labs was the first developer to enhance the Bourne shell by adding csh -like features to it: history, job control, and additional programmability. Eventually, the Korn shells feature set surpassed both that of the Bourne and C shells, while remaining compatible with the former for shell programming. Today, the POSIX standard defines the standard shell language and behavior based on the System V Bourne shell, with a selected subset of features from the Korn shell.
The Free Software Foundation, in keeping with its goal to produce a complete Unix work-alike system, developed a clone of the Bourne shell, written from scratch, named Bash, the Bourne-Again SHell. Over time, Bash has become a POSIX-compliant version of the shell with many additional features overlapping those of the Korn shell, but Bash is not an exact Korn shell clone. Today, Bash is probably the most widely used Bourne-derived shell.
Overview of Features
The Bash shell provides the following features:
- Input/output redirection
- Wildcard characters for filename abbreviation
- Shell variables and options for customizing the environment
- A built-in command set for writing shell programs
- Shell functions, for modularizing tasks within a shell program
- Job control
- Command-line editing (using the command syntax of either vi or Emacs)
- Access to previous commands (command history) and the ability to edit them
- Integer arithmetic
- Arrays and arithmetic expressions
- Command-name abbreviation (aliasing)
- Upwards compliance with POSIX
- Internationalization facilities
- An arithmetic for loop
Invoking the Shell
The command interpreter for the Bash shell ( bash ) can be invoked as follows:
bash [
options
] [
arguments
]
Bash can execute commands from a terminal, from a file (when the first argument is a script), or from standard input (if no arguments remain or if -s
is specified). The shell automatically prints prompts if standard input is a terminal, or if -i
is given on the command line.
On many systems, /bin/sh is a link to Bash. When invoked as sh , Bash acts more like the traditional Bourne shell: login shells read /etc/profile and ~/.profile, and regular shells read $ENV
, if it is set. Full details are available in the bash(1) manpage .
Command-Line Options
Almost all the single-letter command-line options may also beused with the built-in set command (seethe entry for ). The options are:
-c
str
Read commands from string str.
-D
, --dump-strings
Print all $"
"
strings in the program.
-i
Create an interactive shell (prompt for input). May not be used with set .
-l
, --login
Behave as a login shell.
-O
option
Enable shopt option