$ function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
$ urldecode https%3A%2F%2Fgoogle.com%2Fsearch%3Fq%3Durldecode%2Bbash
https://google.com/search?q=urldecode+bash
$ x="http%3A%2F%2Fstackoverflow.com%2Fsearch%3Fq%3Durldecode%2Bbash"
$ y=$(urldecode "$x")
$ echo "$y"
http://stackoverflow.com/search?q=urldecode+bash
bash - How to decode URL-encoded string in shell? - Stack Overflow
本文来自博客园,作者:CharyGao,转载请注明原文链接:https://www.cnblogs.com/Chary/p/16621054.html