shopt-option

patsub_replacement

In Bash 5.2, allows an unquoted ampersand in replacement text to stand for the matched part. Quoting the replacement ampersand keeps it literal. Be explicit in version-sensitive scripts.

Formal Syntax & Structure

bash syntaxbash
shopt -s patsub_replacement

Return Value

exit status

In Bash 5.2, allows an unquoted ampersand in replacement text to stand for the matched part. Quoting the replacement ampersand keeps it literal. Be explicit in version-sensitive scripts.

Working Example

Example Snippetbash
value=abcshopt -s patsub_replacementprintf '%s\n' "${value/b/[&]}"shopt -u patsub_replacementprintf '%s\n' "${value/b/[&]}"
Bash Reference