Skip to content

Instantly share code, notes, and snippets.

@paddy74
Forked from sergeiwaigant/url_encode_string_with_linux_tools.md
Last active October 22, 2024 18:37
Show Gist options
  • Save paddy74/6098d4fea44c362892590a921155315e to your computer and use it in GitHub Desktop.
Save paddy74/6098d4fea44c362892590a921155315e to your computer and use it in GitHub Desktop.
Simply URL encode string with Linux/Bash/Shell tools
# Reference https://stackoverflow.com/a/34407620/13287790
# Requires `jq`
# $ echo -n "encode this" | jq -sRj @uri
# encode%20this
# MY_VAR=$(urlencode "encode this")
echo -n "${1}" | jq -sRj @uri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment