Last active
February 3, 2024 06:24
-
-
Save hctilg/f350269fa338896bfac0365a31a6e654 to your computer and use it in GitHub Desktop.
binary to ascii
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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