
Or to process a file: perl -pli -MURI::Escape -e '$_ = uri_unescape($_)' file decoded_url=$(perl -MURI::Escape -e 'print uri_unescape($ARGV)' "$encoded_url") Or to process a file: python3 -c 'import sys, urllib.parse print((()))' file.new & decoded_url=$(python3 -c 'import sys, urllib.parse print((sys.argv))' "$encoded_url") Or to process a file: python2 -c 'import sys, urllib print urllib.unquote(())' file.new & decoded_url=$(python2 -c 'import sys, urllib print urllib.unquote(sys.argv)' "$encoded_url") There is a built-in function for that in the Python standard library.
Url encode decode how to#
How to decode URL-encoded string in shell? at SO.How to remove URI encoding from file names?.Can wget decode uri file names when downloading in batch?.If you need to remove url encoding from the file names, use deurlname tool from renameutils (e.g. However above syntax won't handle pluses ( +) correctly, so you've to replace them with spaces via sed or as suggested by use the following syntax: decoded=$(input=$' When scripting, you can use the following syntax: input="http%3A%2F%2Fwww" Then every time when you need it, simply go with: $ echo "http%3A%2F%2Fwww" | urldecode You may define it as alias and add it to your shell rc files: $ alias urldecode='sed | xargs -0 printf "%b"'

Note: The above syntax may not convert + to spaces, and can eat all the newlines.


Or the following alternative using echo -e: $ sed -e's/%\(\)/\\\\\x\1/g' file | xargs echo -e Try the following command line: $ sed file | xargs -0 printf "%b"
