Skip to content

Instantly share code, notes, and snippets.

@janhicken
Created October 29, 2024 08:01
Show Gist options
  • Save janhicken/359f0a8d4c33ed192cebd3903e4b2667 to your computer and use it in GitHub Desktop.
Save janhicken/359f0a8d4c33ed192cebd3903e4b2667 to your computer and use it in GitHub Desktop.
URL decoding in pure Bash
#!/usr/bin/env bash
set -o nounset
while read -r line; do
# Convert '+' to ' '
with_spaces="${line//+/ }"
# Decode hex-encoded stuff using \x backslash escapes
printf '%b' "${with_spaces//%/\\x}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment