Reputation: 125
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.
Upvotes: 1
Views: 593
Reputation: 88543
Put your string in a variable then you can use Parameter Expansion:
s="3.9.1"
echo "${s//./\\.}"
Output:
3\.9\.1
Upvotes: 9