Created
January 31, 2019 11:58
-
-
Save openglfreak/2ad95e9a8ecbcf1a166bcd6dd6e827ae to your computer and use it in GitHub Desktop.
Escape a string for use as/in a sed replacement.
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
# Escapes a string for use as/in a sed replacement | |
# https://stackoverflow.com/a/2705678 | |
sed_escape_replacement() { | |
sed -e 's/[\/&]/\\&/g' -e 's/$/\\n/g' | tr -d '\n' | head -c -2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment