I am trying to replace name with a different name, which works but when I have "[]" it doesn't work.
#!/bin/bash
firstString="I love [Candy] Store"
firstChange="[Candy] Store"
secondString="Chocolate Store"
echo "${firstString//$firstChange/$secondString}"
I am expecting:
"I love Chocolate Store".
Working example:
#!/bin/bash
firstString="I love Candy Store"
firstChange="Candy Store"
secondString="Chocolate Store"
echo "${firstString//$firstChange/$secondString}"
Output:
I love Chocolate Store.
I am trying to make it work for both the cases.
Could someone please help me?
Thanks