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.
- (hyphen or minus) character in Bash is a heavily overloaded lexical token. Its behavior is strictly determined by its syntactic context, functioning variously as an arithmetic operator, a parameter expansion modifier, a special parameter, a file descriptor closure token, a pattern matching range indicator, a conditional test prefix, or a directory navigation shortcut.
Arithmetic Operators
Within an arithmetic evaluation context ($(( )), (( )), let, or variables typed with declare -i), - functions as a binary subtraction operator, a unary negation operator, and forms the unary pre-decrement and post-decrement operators (--).
File Descriptor Closure
In redirection operations, appending- to the file descriptor duplication operators (>& or <&) instructs the shell to close the specified file descriptor rather than duplicating it.
Special Parameter (Shell Options)
The hyphen acts as a core special parameter ($-). When expanded, it yields a string containing the current set of single-letter shell option flags enabled in the current Bash environment (e.g., himBH).
Parameter Expansion (Default Value Substitution)
In brace parameter expansion,- acts as a fallback operator. It instructs the shell to evaluate to a specified default string if the target parameter is unset. When combined with a colon (:-), it triggers the fallback if the parameter is either unset or null (empty).
Pattern Matching Range Operator
Within bracket expressions[ ] used in pathname expansion (globbing) and regular expression matching ([[ =~ ]]), - defines a contiguous character range based on the current locale’s collating sequence.
Conditional Test Prefix
Within thetest builtin, POSIX brackets [ ], and Bash extended test keywords [[ ]], - is the required prefix for unary file/string operators and binary algebraic comparison operators.
Here-Document Tab Stripping
When appended to the here-document redirection operator (<<), forming <<-, the hyphen modifies the parsing of the here-document. It instructs the shell to strip all leading tab characters (but not spaces) from the subsequent lines of the document body and the terminating delimiter.
Previous Working Directory Alias
When passed as the sole argument to thecd builtin, - is parsed as a reserved alias for the $OLDPWD environment variable. It instructs the shell to change the current working directory to the previous working directory and prints the new path to standard output.
Option Prefix and End-of-Options Marker
The- character is the standard prefix for short (single-character) options passed to Bash builtins and external commands. Furthermore, a standalone double hyphen (--) is parsed as the end-of-options indicator, forcing all subsequent arguments to be treated as positional parameters (operands), even if they begin with a -.
Master Bash with Deep Grasping Methodology!Learn More





