Skip to content

Instantly share code, notes, and snippets.

@sergeiwaigant
sergeiwaigant / url_encode_string_with_linux_tools.md
Last active April 4, 2026 18:56
Simply URL encode string with Linux/Bash/Shell tools

Reference https://stackoverflow.com/a/34407620/13287790

$ printf %s 'encode this'|jq -sRr @uri
encode%20this

$ jq -rn --arg x 'encode this' '$x|@uri'
encode%20this

# -r (--raw-output) outputs the raw contents of strings instead of JSON string literals. -n (--null-input) doesn't read input from STDIN.