Last active
September 20, 2023 10:48
-
-
Save mator/b981ad3bb26655d52252743a6515c1c8 to your computer and use it in GitHub Desktop.
sed escaped replace
This file contains 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
https://stackoverflow.com/questions/407523/escape-a-string-for-a-sed-replace-pattern | |
ESCAPED_REPLACE=$(printf '%s\n' "$REPLACE" | sed -e 's/[\/&]/\\&/g') | |
# Now you can use ESCAPED_REPLACE in the original sed statement | |
sed "s|KEYWORD|${ESCAPED_REPLACE}|g" | |
if you have "base64 -w 0" string (even multiline), it does not needs to be escaped |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment