How to convert binary numbers to decimal using the bash shell.

Posted: June 16, 2016. At: 8:28 AM. This was 2 years ago. Post ID: 9278
Page permalink.
WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters. These cookies expire two weeks after they are set.

This one-liner will convert binary numbers to decimal. Very easy to do in the bash shell.

[email protected]:~$ echo "$((2#01110100011000010110101101))"
30508461

This is how to convert binary to Hexadecimal.

[email protected]:~$ printf '%x\n' "$((2#1111111))"
7f

These very useful one-liners should make converting number values even easier.

No comments have been made. Use this form to start the conversation :)

Leave a Reply