TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
** operator in Bash serves two distinct technical functions depending on its execution context: it acts as the exponentiation operator within arithmetic evaluation, and as the recursive wildcard (globstar) within pathname expansion.
1. Arithmetic Expansion (Exponentiation)
Within arithmetic contexts—such as$((...)), ((...)), the let builtin, or variables typed with declare -i—the ** token functions as a right-associative exponentiation operator. It evaluates the left operand (base) raised to the power of the right operand (exponent).
Because Bash arithmetic is strictly limited to fixed-width integers (typically 64-bit signed integers), the ** operator does not support floating-point operands. Negative exponents are invalid and will trigger an explicit error (e.g., bash: exponent less than 0), aborting the arithmetic evaluation. Operations exceeding the maximum integer limit will silently overflow.
Unlike other arithmetic operators, Bash does not implement a compound exponentiation assignment operator (**=). The result of an exponentiation must be explicitly assigned back to a variable.
2. Pathname Expansion (Globstar)
During pathname expansion (globbing),** acts as a recursive matching operator. By default, this behavior is disabled and must be explicitly activated using the shopt builtin to set the globstar option (introduced in Bash 4.0).
When globstar is enabled, the ** token matches all files, as well as zero or more directories and subdirectories. The evaluation engine traverses the directory tree recursively. Since Bash 4.3, the ** operator explicitly does not traverse symbolic links that point to directories. This is a vital safety mechanism designed to prevent infinite recursion loops during directory tree traversal.
Crucially, ** does not match hidden files or traverse into hidden directories (those starting with .) unless the dotglob shell option is explicitly enabled via shopt -s dotglob.
- If
**appears alone, it matches all non-hidden files and directories in the current directory tree. - If
**is followed by a slash (**/), the expansion is strictly restricted to directories and subdirectories, excluding standard files. - If
**is part of a larger pattern (e.g.,**/*.txt), it applies the suffix pattern to all files and directories discovered during the recursive traversal.
globstar option is disabled, Bash treats ** identically to a single * (standard wildcard), matching only files and directories in the immediate current working directory.
Master Bash with Deep Grasping Methodology!Learn More





