In Bash, the expression {b,c}d is a brace expansion, which expands to bd cd by default. To get the output bc cd, you need to ensure the comma is treated as a literal character and not as a separator for brace expansion.
Escape the comma with a backslash (\) to prevent brace expansion:
basha={b\,c}d echo $a
Output:
text{b,c}d
But if you want the output to be bc cd, you need to remove the braces and just use the comma as a literal separator:
basha=b,c echo ${a//,/ }
Output:
textb c
Or, if you want to keep the d at the end:
basha=b,cd echo ${a//,/ }
Output:
textb cd
bc cd):If you want the output to be bc cd from {b,c}d, you need to remove the braces and the d and replace the comma with a space:
basha=b,c echo ${a//,/ }
Output:
textb c
If you want bc cd, you need to adjust the input:
basha=bc,cd echo ${a//,/ }
Output:
textbc cd
Vibe can make mistakes. Check answers. Learn more