Difference between revisions of "The bash shell"

From Linux Shell Scripting Tutorial - A Beginner's handbook
Jump to navigation Jump to search
 
(31 intermediate revisions by 9 users not shown)
Line 5: Line 5:
 
Bash is the [[shell]], or command language interpreter, for the [[Linux]] operating system. The name is an acronym for the Bourne-Again SHell, a pun on Stephen Bourne, the author of the direct ancestor of the current Unix shell sh, which appeared in the Seventh Edition Bell Labs Research version of Unix Bash Reference Manual<ref>Bash Reference Manual.</ref>.
 
Bash is the [[shell]], or command language interpreter, for the [[Linux]] operating system. The name is an acronym for the Bourne-Again SHell, a pun on Stephen Bourne, the author of the direct ancestor of the current Unix shell sh, which appeared in the Seventh Edition Bell Labs Research version of Unix Bash Reference Manual<ref>Bash Reference Manual.</ref>.
  
==Introduction to BASH==
+
==Introduction to the Bash Shell==
 +
A command line is a text user interface. One can use such an interface to provide instructions to a Linux powered computer. Under Linux, a programmed called [[shell]] used to provide a Linux command line user interface. The default shell for users in Linux is the GNU bash:
 
* Developed by [[GNU]] project.
 
* Developed by [[GNU]] project.
* The default Linux shell.
+
* The default Linux shell on most [[Linux distributions]].
* Backword-compatible with the original [[sh]] [[UNIX]] [[shell]].
+
* Backward-compatible with the original [[sh]] [[UNIX]] [[shell]].
 
* Bash is largely compatible with sh and incorporates useful features from the Korn shell ksh and the C shell csh.  
 
* Bash is largely compatible with sh and incorporates useful features from the Korn shell ksh and the C shell csh.  
* Bash is the default shell for [[Linux]]. However, it does runs on every version of [[Unix]] and a few other operating systems such as [[ms-dos]], [[os/2]], and [[Windows]] platforms.
+
* Bash is the default shell for [[Linux]]. However, it does run on every version of [[Unix]] and a few other operating systems such as [[ms-dos]], [[os/2]], and [[Windows]] platforms.
  
Quoting from the offcial Bash home page:
+
Quoting from the official Bash home page:
  
 
''Bash is the shell, or command language interpreter, that will appear in the GNU operating system. It is intended to conform to the IEEE POSIX P1003.2/ISO 9945.2 Shell and Tools standard. It offers functional improvements over sh for both programming and interactive use. In addition, most sh scripts can be run by Bash without modification.''
 
''Bash is the shell, or command language interpreter, that will appear in the GNU operating system. It is intended to conform to the IEEE POSIX P1003.2/ISO 9945.2 Shell and Tools standard. It offers functional improvements over sh for both programming and interactive use. In addition, most sh scripts can be run by Bash without modification.''
 +
===The command (shell) prompt===
 +
Typically you see a {{kbd|$}} prompt when bash is waiting for a command from the user. This is called the command prompt or shell prompt. The default command prompt ends with a {{kbd|$}} character for the regular user, and for the root user, the default prompt ends with a {{kbd|#}} character.
 +
 +
[[File:Introduction to the Bash Shell.jpg|frame|center|The default command (shell) prompt for a regular and root user]]
  
 
===The improvements offered by BASH include:===
 
===The improvements offered by BASH include:===
 +
The Bash syntax is an improved version of the Bourne shell syntax. In most cases Bourne shell scripts can be executed by Bash without any problems.
 
* Command line editing.
 
* Command line editing.
 
* Command line completion.
 
* Command line completion.
 
* Unlimited size command history.
 
* Unlimited size command history.
* Job Control.
 
 
* Prompt control.
 
* Prompt control.
* Shell Functions and Aliases.
+
* Indexed arrays of unlimited size (Arrays).
* Indexed arrays of unlimited size.
+
* Integer arithmetic in any base from two to sixty-four.
* Integer arithmetic in any base from two to sixty-four.  
+
* Bash startup files - You can run bash as an interactive login shell, or interactive non-login shell. See [http://bash.cyberciti.biz/bash-reference-manual/Bash-Startup-Files.html Bash startup files] for more information.
 +
* Bash conditional expressions: Used in  composing various expressions for the test builtin or [[ or [ commands.
 +
* The Directory Stack - History of visited directories.
 +
* The Restricted Shell: A more controlled mode of shell execution.
 +
* Bash POSIX Mode: Making Bash behave more closely to what the POSIX standard specifies.
 +
==== Bash v4.0 Features ====
 +
* Usual run time environment: [[POSIX]]
 +
* [[Command and file name completion]] - Bash can automatically fill in partially typed commands or arguments to the commands such as file name, hostname and much more.
 +
* Arithmetic support:
 +
** [[Integer arithmetic]] supported.
 +
** [[Floating point arithmetic]] is not supported.
 +
** [[Exponential notation]] is limited via [[printf builtin]].
 +
** [[Date and time arithmetic]] is not supported.
 +
* [[Hash table]]: Bash uses a hash table to remember the full pathnames of executable files.
 +
* [[Pattern Matching]] and [[Regular expressions|regular expressions]] are supported.
 +
* [[Globbing]] - For example, you can use *.conf to match all those conf files in /etc directory.
 +
* [[Directory stack]] is supported via [[pushd]] and [[popd]] builtins.
 +
* [[Command history]] and [[History completion]] fully supported by Bash.
 +
* [[Custom command prompt]] - Allows you to change the default prompt.
  
 
==Authors==
 
==Authors==
Line 30: Line 53:
 
* Fox maintained [[Bash]] as the primary maintainer until 1993, at which point Chet Ramey took over.
 
* Fox maintained [[Bash]] as the primary maintainer until 1993, at which point Chet Ramey took over.
 
* Chet Ramey is the current maintainer of the GNU Bourne Again Shell and GNU Readline.  
 
* Chet Ramey is the current maintainer of the GNU Bourne Again Shell and GNU Readline.  
 +
 +
=== Download Bash Shell===
 +
* Bash is the default shell under [[Linux]]. The current production versions are Bash 3.x and 4.x. You can grab it from the [http://ftp.gnu.org/gnu/bash/ official website].
  
 
==External links==
 
==External links==
Line 38: Line 64:
 
<references/>
 
<references/>
 
[[Category:Introduction to Shells]]
 
[[Category:Introduction to Shells]]
 +
 +
{{navigation
 +
|previous=Chapter 2: Getting Started With Shell Programming
 +
|next=Shell commands}}

Latest revision as of 16:52, 2 October 2020

← Chapter 2: Getting Started With Shell ProgrammingHomeShell commands →

Bash is the shell, or command language interpreter, for the Linux operating system. The name is an acronym for the Bourne-Again SHell, a pun on Stephen Bourne, the author of the direct ancestor of the current Unix shell sh, which appeared in the Seventh Edition Bell Labs Research version of Unix Bash Reference Manual[1].

Introduction to the Bash Shell

A command line is a text user interface. One can use such an interface to provide instructions to a Linux powered computer. Under Linux, a programmed called shell used to provide a Linux command line user interface. The default shell for users in Linux is the GNU bash:

  • Developed by GNU project.
  • The default Linux shell on most Linux distributions.
  • Backward-compatible with the original sh UNIX shell.
  • Bash is largely compatible with sh and incorporates useful features from the Korn shell ksh and the C shell csh.
  • Bash is the default shell for Linux. However, it does run on every version of Unix and a few other operating systems such as ms-dos, os/2, and Windows platforms.

Quoting from the official Bash home page:

Bash is the shell, or command language interpreter, that will appear in the GNU operating system. It is intended to conform to the IEEE POSIX P1003.2/ISO 9945.2 Shell and Tools standard. It offers functional improvements over sh for both programming and interactive use. In addition, most sh scripts can be run by Bash without modification.

The command (shell) prompt

Typically you see a $ prompt when bash is waiting for a command from the user. This is called the command prompt or shell prompt. The default command prompt ends with a $ character for the regular user, and for the root user, the default prompt ends with a # character.

The default command (shell) prompt for a regular and root user

The improvements offered by BASH include:

The Bash syntax is an improved version of the Bourne shell syntax. In most cases Bourne shell scripts can be executed by Bash without any problems.

  • Command line editing.
  • Command line completion.
  • Unlimited size command history.
  • Prompt control.
  • Indexed arrays of unlimited size (Arrays).
  • Integer arithmetic in any base from two to sixty-four.
  • Bash startup files - You can run bash as an interactive login shell, or interactive non-login shell. See Bash startup files for more information.
  • Bash conditional expressions: Used in composing various expressions for the test builtin or [[ or [ commands.
  • The Directory Stack - History of visited directories.
  • The Restricted Shell: A more controlled mode of shell execution.
  • Bash POSIX Mode: Making Bash behave more closely to what the POSIX standard specifies.

Bash v4.0 Features

Authors

  • Brian J. Fox authored the GNU Bash shell, in 1987.
  • Fox maintained Bash as the primary maintainer until 1993, at which point Chet Ramey took over.
  • Chet Ramey is the current maintainer of the GNU Bourne Again Shell and GNU Readline.

Download Bash Shell

  • Bash is the default shell under Linux. The current production versions are Bash 3.x and 4.x. You can grab it from the official website.

External links

References

  1. Bash Reference Manual.

← Chapter 2: Getting Started With Shell ProgrammingHomeShell commands →