shell replace substring in string code example
Example 1: bash replace substring
echo [string] | sed "s/[original]/[target]/g"
Example 2: bash replace substring in string
#!/bin/bash
firstString="I love Suzi and Marry"
secondString="Sara"
echo "${firstString/Suzi/$secondString}"
# prints 'I love Sara and Marry'