Skip to content

Instantly share code, notes, and snippets.

@bahamat
Last active December 20, 2020 01:05
Show Gist options
  • Save bahamat/7c4abade72d674e34281 to your computer and use it in GitHub Desktop.
Save bahamat/7c4abade72d674e34281 to your computer and use it in GitHub Desktop.
Magical quoting with printf %q
$ echo quote what? ; read quoteme ; printf %q "$quoteme" ; echo
quote what?
The horse said "$)#*@(!!%" when he stubbed his hoof.
The\ horse\ said\ \"\$\)#\*@\(\!\!%\"\ when\ he\ stubbed\ his\ hoof.
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment