I have \"I love Suzi and Marry\" and I want to change \"Suzi\" to \"Sara\".
#!/bin/bash
firstString=\"I love Suzi and Marry\"
secondString=\"Sara\"
# do some
For Dash all previous posts aren't working
The POSIX sh
compatible solution is:
result=$(echo "$firstString" | sed "s/Suzi/$secondString/")
This will replace the first occurrence on each line of input. Add a /g
flag to replace all occurrences:
result=$(echo "$firstString" | sed "s/Suzi/$secondString/g")