0

Duplicate of https://unix.stackexchange.com/questions/159253/decoding-url-encoding-percent-encoding, but SO does not understand url from different stack.

Inside a docker container, I use environment variables (that I do not manage initialy, so I cannot act on them) inside a bash script.

One of the environement variable has one hexa character, but the rest of the string is OK.

Original string is: toto@t.

It is recuperated as toto%40t in the script with the following command:

echo "$VAR"

Note the @ that is transformed into %40

With "minimal Ubuntu 20" (Installation of additionnal tools is possible, but I want to avoid it), pure bash if possible, how can I format the variable to get the original format ?

Itération 122442
  • 2,644
  • 2
  • 27
  • 73
  • https://unix.stackexchange.com/questions/159253/decoding-url-encoding-percent-encoding https://stackoverflow.com/questions/11876353/url-encoding-a-string-in-bash-script https://stackoverflow.com/questions/6250698/how-to-decode-url-encoded-string-in-shell – KamilCuk Apr 21 '21 at 14:32
  • @Inian I do not know about the `%`. From https://www.nicolas-hoffmann.net/utilitaires/codes-hexas-ascii-unicode-utf8-caracteres-usuels.php, `%40` is the equivalent from `@`. Concerning other characters, so far no problem, but it could be a problem in the future if the variables are updated. – Itération 122442 Apr 21 '21 at 14:33
  • @KamilCuk https://unix.stackexchange.com/questions/159253/decoding-url-encoding-percent-encoding saved the day. Closing. – Itération 122442 Apr 21 '21 at 14:50

0 Answers0