Skip to content

Instantly share code, notes, and snippets.

@mator
Last active September 20, 2023 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mator/b981ad3bb26655d52252743a6515c1c8 to your computer and use it in GitHub Desktop.
Save mator/b981ad3bb26655d52252743a6515c1c8 to your computer and use it in GitHub Desktop.
sed escaped replace
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