8.31.2015

convert hex to binary in bash shell on linux

remember hex must be in uppercase for BC command on most linux / unix distros

echo "ibase=16;obase=2;000000004B817EFB" | bc
results:
1001011100000010111111011111011
space it out to make it easier to read:
alias spc=" sed 's/./& /g'"
echo "ibase=16;obase=2;000000004B817EFB" | bc | spc
1 0 0 1 0 1 1 1 0 0 0 0 0 0 1 0 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 

No comments: