Skip to content

Instantly share code, notes, and snippets.

@thinkerbot
Created October 19, 2012 04:41
Show Gist options
  • Save thinkerbot/3916274 to your computer and use it in GitHub Desktop.
Save thinkerbot/3916274 to your computer and use it in GitHub Desktop.
Hex-escape sensitive command line characters

Description

Hex-escape sensitive tcl/shell characters

Usage

printf $(printf "\x26\x3b\x60\x27\x22\x7c\x2a\x3f\x7e\x3c\x3e\x5e\x28\x29\x5b\x5d\x7b\x7d\x24\x5c\n" | ./escape)
# &;`'"|*?~<>^()[]{}$\

Close ...

printf $(printf "\x26\x3b\x60\x27\x22\x7c\x2a\x3f\x7e\x3c\x3e\x5e\x28\x29\x5b\x5d\x7b\x7d\x24\x5c\n" | od -A n -t x1 | awk 'BEGIN {ORS=""}; { gsub(/ +/, "\\x"); print }')

&;`'"|*?~<>^()[]{}$\

#!/usr/bin/sed -f
s/\\/\\x5c/g
s/&/\\x26/g
s/;/\\x3b/g
s/`/\\x60/g
s/'/\\x27/g
s/"/\\x22/g
s/|/\\x7c/g
s/*/\\x2a/g
s/?/\\x3f/g
s/~/\\x7e/g
s/</\\x3c/g
s/>/\\x3e/g
s/\^/\\x5e/g
s/(/\\x28/g
s/)/\\x29/g
s/\[/\\x5b/g
s/]/\\x5d/g
s/{/\\x7b/g
s/}/\\x7d/g
s/\$/\\x24/g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment