Skip to content

Instantly share code, notes, and snippets.

@kennedyj
Created January 30, 2012 23:31
Show Gist options
  • Save kennedyj/1707505 to your computer and use it in GitHub Desktop.
Save kennedyj/1707505 to your computer and use it in GitHub Desktop.
Convert Hex to Bin in bash
#!/bin/bash
if [ ! -n $1 ]; then
echo "Must specify a value"
exit 1
fi
for var in "$@"
do
code=`echo $var | tr 'a-z' 'A-Z'`
converted=`echo "ibase=16; $code" | bc`
echo -n "$converted "
done
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment