Jump to content

Bash

From Simple English Wikipedia, the free encyclopedia

Bash is the name of a shell, a kind of computer program used to give commands, run scripts, and receive results in textual form. Bash is also the command language used by Bash shell.

Bash shell is present in almost every Linux distribution, where is very often the default shell, and otherwise accessible via the bash commmand. Bash is also present in MacOS (not default), and not on Windows.

Bash shell (and shells in general) can work in two modes:

  • non-interactive mode, designed to let other programs run commands or scripts, usually without any window;
  • interactive mode, designed to let the user give commands (that may launch scripts) through a "terminal" window.

Scripts may be launched in either of the two modes, and scripts can be written so they do different stuff in the two modes.

Scripts are plain text files containing commands. Scripts are not programs, because they need a program to open them and execute them. A Bash script needs Bash shell, while others (eg: Fish scripts) need a different one (eg: Fish shell).

Bash scripts usually begin with a line like #!/usr/bin/env bash or #!/bin/bash. This line is called shebang, and serves to tell the Operating System to run the script with Bash (eg: when double-clicking the script. Note that only the OS uses the shebang, shells usually ignore them).

Compatibility

[change | change source]

Bash language is based on POSIX, a standard used by many other shells, but it also has some additional commands, which are rarely copied / supported by other shells. Therefore some Bash scripts can also run in some other shells, but this varies from case to case.

See also

[change | change source]
[change | change source]