This was previously asked at the below url, but only done using the a forward-slash as the delimiter. https://stackoverflow.com/a/11245501/2520289
What is the proper syntax to do the exact same thing but with any of the other compatible delimiters for sed?
I have the delimiter changed for universal compatibility across most bash environments. (git-bash/any linux)
For example, I am currently doing the below snippet to replace any matches of the specific string but not the whole line.
function misc_findReplace()
{
VARIABLE_FIND="$1"
VARIABLE_REPLACE="$2"
VARIABLE_FILE="$3"
echo "Finding: $VARIABLE_FIND"
echo "Replacing With: $VARIABLE_REPLACE"
echo "File to Operate On: $VARIABLE_FILE"
sed -i "s@${VARIABLE_FIND}@c${VARIABLE_REPLACE}@g" "$VARIABLE_FILE"
}
FILE_TO_WORK_WITH="/path/to/my/file.properties"
STRING_TO_FIND="destination_hostname=<destination_hostname>"
STRING_TO_REPLACE="destination_hostname=localhost"
misc_findReplace "$STRING_TO_FIND" "$STRING_TO_REPLACE" "$FILE_TO_WORK_WITH"