Bash
Bash is the default command-line shell on most Linux distributions and macOS. It interprets commands, manages processes, and provides a scripting language for automating system administration tasks, file manipulation, and pipeline orchestration.
itLinux | OpenSkills.info
Intro
Bash
Bash is both a command interpreter and a programming language. You use it interactively to run programs. You also place commands in scripts to automate repeatable work.
The name means Bourne-Again Shell. Bash builds on the traditional Bourne shell and adds features for interactive work and programming. It is largely compatible with sh, but Bash also has its own syntax and behavior.
The mental model
A Bash command line is not passed to a program exactly as you type it. Bash processes the text first.
input
-> tokens and syntax
-> expansions
-> redirections
-> command execution
-> exit status
This processing model explains many surprises. A variable can become several arguments. A wildcard can become many filenames. A redirection can change where output goes before a command starts.
Quoting controls this processing. Single quotes preserve literal characters. Double quotes still allow selected expansions, including parameter expansion and command substitution. As a default, quote parameter expansions unless you specifically want word splitting or filename expansion.
name='Quarterly report'
printf '%s\n' "$name"
Here, "$name" becomes one argument. Without the double quotes, the result can be split into separate words.
Continue the course
This section is part of the paid course.
See pricing to subscribe, or log in if you already have access.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://www.gnu.org/software/bash/
Supports
- Bash as the GNU Project shell and a largely sh-compatible shell
- Bash features for interactive and programming use
- Official routes to releases, documentation, support, and development
- Rationale for the GNU Bash Project link
- https://www.gnu.org/software/bash/manual/bash.html
Supports
- Bash as both command interpreter and programming language
- Builtins, parameters, expansions, redirections, command execution, and control flow
- Interactive features including history, job control, aliases, and command-line editing
- Bash relationship to sh and its POSIX conformance intent
- Complete-manual link rationale and quiz answers about Bash roles and suitable boundaries
- https://www.gnu.org/software/bash/manual/html_node/Shell-Operation.html
Supports
- Ordered command processing from input through status collection
- Tokenization, parsing, expansion, redirection, and execution mental model
- Shell Operation link rationale
- https://www.gnu.org/software/bash/manual/html_node/Quoting.html
Supports
- Quoting as control over special character and word meaning
- Escape, single-quote, double-quote, and dollar-single-quote mechanisms
- Quoting link rationale and quiz answer about quoted parameter expansion
- https://www.gnu.org/software/bash/manual/html_node/Shell-Expansions.html
Supports
- Expansion order and expansion families
- Word splitting, filename expansion, and quote removal
- Parameter, command, and arithmetic expansion anchors
- Shell Expansions link rationale
- https://www.gnu.org/software/bash/manual/html_node/Redirections.html
Supports
- Input, output, append, standard-error, and descriptor redirections
- Redirections processed from left to right
- Here documents, here strings, and descriptor duplication
- Redirections link rationale and redirection-order quiz answer
- https://www.gnu.org/software/bash/manual/html_node/Pipelines.html
Supports
- Pipeline connection from one command's output to the next command's input
- Default pipeline status and pipefail behavior
- Pipeline execution environments and foreground waiting behavior
- Quiz answers about pipeline data flow and status
- https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
Supports
- Zero as success and nonzero as failure
- Status range and special 126 and 127 meanings
- Last status available through the question-mark special parameter
- Status-based conditional design and related quiz answers
- https://www.gnu.org/software/bash/manual/html_node/Shell-Scripts.html
Supports
- Scripts as text files containing shell commands
- Non-interactive execution, positional parameters, execute bits, and interpreter lines
- Explicit Bash invocation and environment-based interpreter lookup idiom
- Shell Scripts link rationale and interpreter-policy quiz answer
- https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html
Supports
- Login, interactive non-login, and non-interactive startup behavior
- Interactive non-login reading of the user bash configuration file
- Quiz answer about startup files
- https://www.gnu.org/software/bash/manual/html_node/Arrays.html
Supports
- One-dimensional indexed and associative Bash arrays
- Array declaration, assignment, indexing, and quoted at expansion
- Quiz answer about declaring Bash for Bash-specific array use
- https://www.gnu.org/software/bash/manual/html_node/Bash-Conditional-Expressions.html
Supports
- File, string, and arithmetic conditional expressions
- Behavior of expressions inside double-bracket conditionals
- Quiz answer about Bash-specific conditional syntax
- https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html
Supports
- Current-shell behavior of builtins including change directory, export, source, and exit
- Export marking names for subsequently executed command environments
- Quiz answer about why change directory is a builtin
- https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
Supports
- Shell option behavior for nounset, errexit, tracing, and pipefail
- Limits and context sensitivity of option-based error handling
