Skip to content

Instantly share code, notes, and snippets.

@sitkevij
Created May 18, 2012 18:21
Show Gist options
  • Save sitkevij/6b76c92fdb9e4a355f3c to your computer and use it in GitHub Desktop.
Save sitkevij/6b76c92fdb9e4a355f3c to your computer and use it in GitHub Desktop.
bash script to convert a string from hex to decimal
HEX=c9fc17d693b58ad31448d1177728964591ad1c720b545a05c700395c980a7029
i=1
while (( i <= ${#HEX} ))
do
char=$(expr substr "$HEX" $i 2)
# echo "<$char>"
printf "%d\n" 0x$char
(( i += 2 ))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment