How to convert hex to dec in Linux terminal?

pikoTutorialpikoTutorial
1 min read

Welcome to the next pikoTutorial!

Conversion from hexadecimal to decimal

Add the following function to your .bashrc file:

function todec {
    echo "ibase=16; $1" | bc
}

Usage:

~$ todec AA12CE
11145934

Conversion from decimal to hexadecimal

Add the following function to your .bashrc file:

function tohex {
    echo "obase=16; $1" | bc
}

Usage:

~$ tohex 11145934
AA12CE
0
Subscribe to my newsletter

Read articles from pikoTutorial directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

pikoTutorial
pikoTutorial