linux command line convert binary to hex with bash function

Put this function in your .bashrc (or wherever):

bin2hex() {
   echo "obase=16;ibase=2;$1"|bc
}

Remember to install

bc

if you don’t have it already.

# bin2hex 10011111
9F

One thought on “linux command line convert binary to hex with bash function

Leave a Reply

Your email address will not be published. Required fields are marked *