I'm trying to do a string substitution in bash to escape the dots in a version number to ultimately pass to grep. When I run
echo ${3.9.1//./\\.}
Expected output is 3\.9\.1
. I get a bad substitution
error instead. I don't understand how this isn't correct.
CodePudding user response:
Put your string in a variable then you can use Parameter Expansion:
s="3.9.1"
echo "${s//./\\.}"
Output:
3\.9\.1