Bash-URL-decode: Difference between revisions
Jump to navigation
Jump to search
(Created page with "=== URL decode in bash === <pre> #!/bin/bash function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } urldecode "$(cat $1)" </pre> [https://stackoverflow.com/questions/6...") |
mNo edit summary |
||
Line 6: | Line 6: | ||
</pre> | </pre> | ||
[https://stackoverflow.com/questions/6250698/how-to-decode-url-encoded-string-in-shell|Stack overflow source and details] | [https://stackoverflow.com/questions/6250698/how-to-decode-url-encoded-string-in-shell|Stack overflow source and details] | ||
<pre> | |||
$ x="http%3A%2F%2Fstackoverflow.com%2Fsearch%3Fq%3Durldecode%2Bbash" | |||
$ y=$(urldecode "$x") | |||
$ echo "$y" | |||
http://stackoverflow.com/search?q=urldecode+bash | |||
</pre> | |||
[[Category:Bash]] | [[Category:Bash]] |
Latest revision as of 07:50, 15 August 2022
URL decode in bash
#!/bin/bash function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } urldecode "$(cat $1)"
$ x="http%3A%2F%2Fstackoverflow.com%2Fsearch%3Fq%3Durldecode%2Bbash" $ y=$(urldecode "$x") $ echo "$y" http://stackoverflow.com/search?q=urldecode+bash