How can I url-encode all characters in bash?
For example:
abcd0123 => %61%62%63%64%30%31%32%33
I tried the built-in urlencode function in Linux but it only encodes special characters like (.?)
I don't believe this is possible in pure Bash, but other shell utilities can be strung together to achieve this result, for example
urlencode() {
printf %s "$1" | od -An -tx1 -v -w${#1} | tr ' ' %
}
urlencode abcd0123 # => %61%62%63%64%30%31%32%33