-
-
Save Chris2048/3160887 to your computer and use it in GitHub Desktop.
sed sanitise bash function
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
# Use this shell function to sanitise variables before using them with sed, | |
# or in another context where escapes might be substituted | |
funtion san { | |
echo "$1" | tr -d '\n' | xxd -plain | sed 's/\(..\)/\\x\1/g' | tr -d '\n'; } | |
# Use it like this | |
# somevar=$(san "$somevar") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment