Created
October 12, 2021 17:49
-
-
Save eastside/aa4ed0a774a3693b8559eee19f884f95 to your computer and use it in GitHub Desktop.
Find and replace bash script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put the thing you need to find here, like this gnarly SQL. | |
# It has a bunch of annoying characters that sed doesn't like, | |
# so we have to escape them. | |
KEYWORD="SET @@GLOBAL.GTID_PURGED=/*!80000 '+'*/ '';"; | |
# Escape the gnarly stuff | |
ESCAPED_KEYWORD=$(printf '%s\n' "$KEYWORD" | sed -e 's/[]\/$*.^[]/\\&/g'); | |
# Now we can find and replace the now-escaped text | |
sed "s/$ESCAPED_KEYWORD/$ESCAPED_REPLACE/g" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment