Skip to content

Instantly share code, notes, and snippets.

@hctilg
Last active February 3, 2024 06:24
Show Gist options
  • Save hctilg/f350269fa338896bfac0365a31a6e654 to your computer and use it in GitHub Desktop.
Save hctilg/f350269fa338896bfac0365a31a6e654 to your computer and use it in GitHub Desktop.
binary to ascii
#!/usr/bin/env bash
if [ -t 0 ]; then
read -p "b: " binary_text
else
binary_text=$(cat -)
fi
binary_array=($binary_text)
for binary_number in "${binary_array[@]}"
do
decimal_number=$((2#"$binary_number")):
printf "$(printf '\\x%x' $decimal_number)";
done
echo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment