Code Reference

Glossary

Bash · Reference cheat sheet

Glossary

Bash · Reference cheat sheet


📋 Overview

Alphabetical glossary of core Bash terms for shells, scripting, expansion, pipelines, and process control.

🔧 Core concepts

TermDefinition
AliasA short name that expands to a longer command string.
ArgumentA token passed to a command after its name.
ArrayAn indexed list of strings accessible as $\{arr[i]\}.
Brace expansionGenerating multiple strings from patterns like \{a,b\} or \{1..5\}.
BuiltinA command implemented inside the shell, not as an external binary.
Command substitutionCapturing a command’s output with $(...) or backticks.
ConditionalAn if/[[ ]]/case construct that branches on tests.
Exit codeAn integer status ($?) where 0 usually means success.
ExpansionTransformations Bash applies before running a command (variables, globs, etc.).
FunctionA named compound command defined in the shell.
GlobA filename pattern using *, ?, or [] that expands to matching paths.
Here-docA multiline string redirected into a command via &lt;<EOF.
IFSInternal Field Separator used for word splitting and some expansions.
JobA pipeline managed by the shell’s job control (fg, bg, jobs).
LoopA for, while, or until construct that repeats commands.
OptionA flag such as -x or set -e that changes shell behavior.
PipeConnecting one command’s stdout to another’s stdin with `
Process substitutionTreating a command’s output as a file via &lt;(...) or >(...).
QuotingRules (', ", \) that control whether expansion occurs.
RedirectionSending stdin/stdout/stderr to files or other descriptors (>, 2>, &>).
ShebangThe #!/bin/bash line that selects the interpreter for a script.
SignalAn OS notification such as SIGINT that processes can trap or ignore.
SubshellA child shell environment created by (...) or some pipelines.
TrapA handler that runs commands when a signal or exit occurs.
VariableA named string storage slot such as NAME=value and $NAME.
Word splittingBreaking unquoted expansions on IFS characters into multiple fields.

💡 Examples

Variables, quoting, and exit codes:

name="Ada Lovelace"
echo "Hello, $name"
grep -q pattern file.txt
echo $?

Pipes and redirection:

ps aux | grep nginx | awk '{print $2}' > pids.txt 2>/dev/null

Arrays and globbing:

files=(*.md)
echo "${#files[@]} files"
printf '%s\n' "${files[@]}"

⚠️ Pitfalls

  • Confusing single quotes (literal) with double quotes (allow $ and ` expansion).
  • Mixing array indexing with string variables — unquoted $arr is not safe iteration.
  • Treating exit code 0 as false in if — in Bash, 0 is success/true.
  • Equating a subshell (cd /tmp; ...) with changing the parent shell’s directory.
  • Assuming glob failure always errors — unmatched globs may stay literal depending on options.

On this page