Buscar..


Ejemplo simple

URL codificada

http% 3A% 2F% 2Fwww.foo.com% 2Findex.php% 3Fid% 3Dqwerty

Usa este comando para decodificar la URL

echo "http%3A%2F%2Fwww.foo.com%2Findex.php%3Fid%3Dqwerty" | sed -e "s/%\([0-9A-F][0-9A-F]\)/\\\\\x\1/g" | xargs -0 echo -e

URL decodificada (resultado del comando)

http://www.foo.com/index.php?id=qwerty

Usando printf para decodificar una cadena

#!bin/bash
    
$ string='Question%20-%20%22how%20do%20I%20decode%20a%20percent%20encoded%20string%3F%22%0AAnswer%20%20%20-%20Use%20printf%20%3A)'
$ printf '%b\n' "${string//%/\\x}"

# the result
Question - "how do I decode a percent encoded string?"
Answer   - Use printf :)


Modified text is an extract of the original Stack Overflow Documentation
Licenciado bajo CC BY-SA 3.0
No afiliado a Stack Overflow