conditional-operator

Bash == pattern comparison

Tests a shell pattern inside double brackets; quoted parts are literal. In single brackets Bash accepts == as literal equality.

Formal Syntax & Structure

bash syntaxbash
[[ string == pattern ]]

Return Value

exit status

Tests a shell pattern inside double brackets; quoted parts are literal. In single brackets Bash accepts == as literal equality.

Working Example

Example Snippetbash
name=report.txtpattern='*.txt'[[ $name == $pattern ]]; printf '%s\n' "$?"[[ $name == "$pattern" ]]; printf '%s\n' "$?"
Bash Reference