Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Bash (Unix shell)
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== List of Short Descriptions === <!-- Suggestion 3 / 8 -- 06 Jan 2025 --> {{prose|date=January 2025}} As a [[Command-line interface|command processor]], Bash can operate in two modes: an interactive and non-interactive mode. In the interactive mode a [[Terminal emulator|text window]] where users input commands to execute various tasks. The second mode, is execution of commands from files, known as [[shell script]]s, facilitating [[automation]]. In keeping with [[Unix shell]] conventions, Bash incorporates a rich set of features, including: * A [https://www.gnu.org/software/bash/manual/index.html User Manual] provided by the GNU Project, also available at <code>info bash</code>, and a technical manual available at <code>man bash</code>. * [[Function (computer programming)|Invocation]] as a... ** [[Interactivity|Interactive]] shell, ** Non-interactive shell, or ** Login shell; * A [[command-line interface]]; * [[Exit status]] codes; * [[Control flow|Control structures]] for ** [[Conditional (computer programming)|Condition testing]], *** <code>if</code>, <code>case</code>, <code>select</code>, *** logical AND (<code>&&</code>) and OR (<code>||</code>), and ** [[Iteration]]: *** <code>for</code>, <code>while</code>, <code>until</code> loops, and *** Arithmetic C-style loop: <code>for ((</code>; * Syntaxes for Boolean testing of file attributes, string and integer values, etc.: ** Traditional <code>test</code> command, ** Traditional single bracket test: <code>[</code>, ** Modern double bracket test: <code> [[ ... ]]</code>, which includes advanced features: *** Extended [[regular expression]] and extglob matching *** Lexicographic sorting with <code><</code> and <code>></code>; * [[Unix|UNIX]]-style [[Pipeline (Unix)|pipelines]]: <code>|</code>; * [[Child process|Subshells]]: <code>$( ... )</code>; * [[Signal (IPC)|Signaling]] as a means of [[inter-process communication]] using the <code>trap</code> builtin; * Asynchronous execution, i.e., [[Job (computing)|Jobs]] and [[Job control (Unix)|job control]]: ** <code>job_spec &</code> where <code>job_spec</code> can be one of: *** A full commandline: <code><command_name> <options> <operands> <arguments> &</code>, or *** A job control identifier as denoted by a leading percent symbol: <code>%1 &</code>; * A shell [[Porting|portability]] mode where command lines can be interpreted in conformance with the [[POSIX terminal interface|POSIX]] standard; * Command parsing: ** Comments are ignored: *** Bourne-style <code>#</code> hashtag comments, and *** Thompson-style <code>:</code> colon comments; ** Commands are parsed one line at a time: *** Control structures are honored, and *** Backslash <code>\</code> escapes are also honored at the ends of lines; ** Split into words (i.e., [[Text segmentation|word splitting]]) according to [[String literal|quoting]] rules, *** Including ANSI-C quoting <code>$'...'</code>; ** Seven kinds of expansions are performed in the following order on the resulting string: *** (Step 1) Brace expansion <code>kernel{-headers}</code>, *** (Step 2) Tilde expansion <code>~</code>, *** (Step 3) In a left-to-right fashion: **** [[Parameter (computer programming)|Parameter]] and [[Variable (computer science)|variable]] expansion <code>$foo</code> or <code>${bar}</code>, including ***** [[Scope (computer science)#Dynamic scoping|Dynamically scoped]] variables, ***** Indexed [[Array (data type)|arrays]] of unlimited size, ***** [[Associative array]]s via <code>declare -A</code>, and ***** Expansion syntaxes which can perform some tasks more quickly than external utilities, including, among others: ****** Pattern Substitution ******* <code>${foo//x/y}</code> for <code>sed 's/x/y/g'</code>, ****** Remove Matching Prefix or Suffix Pattern ******* <code>${bar##[a-zA-Z0-9]*}</code> for <code>cut -c8-</code>, ****** Print Array Keys ******* <code>${!array[@]}</code>, and ****** Display Error if Null or Unset ******* <code>${var:?error message}</code>, **** [[Command substitution]]: <code>$( ... )</code>, **** [[Process substitution]], <code><()</code> or <code>>()</code>, when a system supports it: **** Arithmetic expansion, <code>(( ... ))</code> or <code>$(( ... ))</code>, including ***** Integer [[arithmetic]] in any [[Radix|base]] from two to sixty-four, although ***** [[Floating-point arithmetic]] is not available from within the shell itself (for this functionality, see current versions of [[Bc (programming language)|<code>bc</code>]] and [[AWK|<code>awk</code>]], among others), *** (Step 4) [[Text segmentation|Word splitting]] (again), *** (Step 5) Pathname expansion, i.e., shell-style [[Glob (programming)|globbing]] and [[pattern matching]] using <code>*</code>, <code>?</code>, <code>[...]</code>, and **** (Although they can be used in conjunction, the use of brackets in pattern matching, <code>[...]</code>, and the use of brackets in the testing commands, <code>[</code> and <code> [[ ... ]]</code>, are each one different things.) *** [[String literal|Quote]] removal; ** [[Redirection (computing)|Redirections]] of Standard Input, Standard Output and Standard Error [[Standard streams|data streams]] are performed, including *** File writing, <code>></code>, and appending, <code>>></code>, *** [[Here document]]s, <code><<</code>, *** Here strings, <code><<<</code>, which allow parameters to be used as input, and *** A redirection operator, <code>>|</code>, which can force overwriting of a file when a shell's "noclobber" setting is enabled; ** Command name lookup is performed, in the following order: *** [[Command (computing)|Commands]] internal to the [[Shell (computing)|shell]]: **** [[Alias (command)|Shell aliases]], **** Shell reserved words, **** [[Function (computer programming)|Shell functions]], and **** [[Shell builtin|Shell built-in commands]]; *** Commands external to the shell: **** Separate [[Unix|UNIX]]-style programs such as [[ls|<code>ls</code>]] or [[Ln (Unix)|<code>ln</code>]], and **** [[Shell script]]s, which are [[File system|files]] containing executable commands. (Shell scripts do not require compilation before execution and, when certain requirements are met, can be invoked as commands by using their filename.) ** The resulting string is executed as a command. Bash also offers... * Configurable execution environment(s):<ref>{{Cite web |title=Command Execution Environment (Bash Reference Manual) |url=https://www.gnu.org/software/bash/manual/html_node/Command-Execution-Environment.html |website=www.gnu.org}}/</ref> ** Shell and [[Session (computer science)|session]] startup files such as <code>~/.bashrc</code> and <code>~/.profile</code> (i.e., [[Hidden file and hidden directory|dotfiles]]); ** Settings (<code>set</code> [[Shell builtin|built-in]]) and shell options (<code>shopt</code> [[Shell builtin|built-in]]) which alter shell behavior; * Support for [[Unicode]]; * With interactive invocation only, ** Unlimited size [[command history]], ** A directory stack (see <code>pushd</code> and <code>popd</code> built-ins), ** [[Command-line completion|Tab completion]], ** Configurable [[Command-line interface#Command prompt|prompts]], and ** Command line editing with [[GNU Readline|GNU readline]]; * Lightweight [[Logging (computing)|logging]] for [[debugging]] purposes (xtrace), and other lightweight debugging options (errexit, noexec, nounset, pipefail, etc.); * Shell [[compatibility mode]]s: bash 5.1 can operate as if it were bash 4.2, etc.; * Various Built-In Commands: ** <code>cd</code> ** <code>pwd</code> * Documentation: ** A built-in <code>help</code> command. ** A [[man page]], and ** An [[Info (Unix)|info page]] which is the same as the GNU manual; * Informal avenues of support via: ** IRC at libera.chat #bash ** Mailing lists at [https://www.gnu.org/software/bash/ Bash - GNU Project - Free Software Foundation]
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Bash (Unix shell)
(section)
Add topic