Skip to content

Instantly share code, notes, and snippets.

@santaklouse
Created February 26, 2025 09:11
Show Gist options
  • Save santaklouse/f53da3180c4e29d7f675d1ebad8ccf8f to your computer and use it in GitHub Desktop.
Save santaklouse/f53da3180c4e29d7f675d1ebad8ccf8f to your computer and use it in GitHub Desktop.
hex to string bash function
#!/usr/bin/env bash
# echo 68656c6c6f20776f726c64|hex2string -> hello world
function hex2string(){
i=${1:-$(</dev/stdin)};
spaced=$(echo "$i"|fold -w2);
for i in ${spaced[@]}; do
echo -n -e "\x$i";
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment