Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt

Use this file to discover all available pages before exploring further.

The ^^ operator is a parameter expansion modifier in Bash (version 4.0 and later) that converts lowercase characters in a variable’s value to uppercase during expansion. It evaluates the string against an optional glob pattern and applies the case transformation to every matching character across the entire string.
${parameter^^pattern}
${parameter^^}

Mechanics and Behavior

  • parameter: The identifier of the variable being expanded.
  • pattern: A standard Bash pathname expansion (globbing) pattern. The pattern is evaluated against each individual character in the expanded string, not the string as a whole.
  • Default Evaluation: If pattern is omitted, Bash implicitly uses the ? glob pattern, which matches and converts every character in the string.
  • Non-destructive Execution: The operator performs an in-memory transformation during the evaluation step. It does not mutate the underlying value stored in parameter.
  • Array Propagation: When applied to an indexed or associative array using the @ or * subscripts (${array[@]^^}), the operator iterates through the array and applies the uppercase transformation to the value of every element individually.

Syntax Examples

Global Conversion (Omitted Pattern) Omitting the pattern converts all characters.
str="alpha beta"
echo "${str^^}"

# Output: ALPHA BETA
Targeted Conversion (Explicit Pattern) Providing a pattern restricts the transformation to matching characters.
str="alpha beta"
echo "${str^^[aeiou]}"

# Output: AlphA bEtA
Array Expansion Applying the operator to the @ subscript transforms all elements.
arr=("foo" "bar" "baz")
echo "${arr[@]^^}"

# Output: FOO BAR BAZ
Master Bash with Deep Grasping Methodology!Learn More