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.
^ (caret) character in Bash is a context-dependent operator that performs five distinct operations based on the parsing environment: parameter expansion, arithmetic evaluation, bracket expression negation, regular expression anchoring, and history expansion.
1. Parameter Expansion (Case Modification)
Introduced in Bash 4.0, the ^ operator within parameter expansion modifies lowercase alphabetic characters to uppercase.
- A single
^modifies only the first character of the expanded parameter. - A double
^^modifies all characters of the expanded parameter. - An optional pattern can follow the operator to restrict the modification to characters matching the pattern. If omitted, the pattern defaults to
?(matches any single character). - When applied to an array subscripted with
@or*, or to positional parameters ($@or$*), the case modification applies to each element individually rather than treating the expanded array as a single string.
$((...)) or ((...))), the ^ operator functions as a bitwise Exclusive OR (XOR) operator. It evaluates the binary representations of two integer operands, returning 1 in each bit position where the corresponding bits of either, but not both, operands are 1.
[ in a bracket expression, ^ negates the character class. It instructs the parser to match any single character not enclosed in the brackets. This applies to both filename expansion (globbing) and pattern matching constructs (such as case statements or the [[ == ]] operator). In Bash, ^ is synonymous with ! in this context.
=~ binary operator within a [[ ... ]] conditional construct, ^ functions as a POSIX Extended Regular Expression (ERE) anchor. It acts as a zero-width assertion that binds the subsequent pattern strictly to the beginning of the string.
^ operator acts as a history expansion designator strictly within an interactive shell environment. It is a syntactic shorthand for the !!:s/string1/string2/ history substitution command. It retrieves the immediately preceding command from the history list, replaces the first occurrence of the first string with the second string, and evaluates the modified command. Because history expansion is disabled by default in non-interactive shells, this syntax will fail or be treated as a literal string if placed in a standard Bash script.
Master Bash with Deep Grasping Methodology!Learn More





