To convert a hexadecimal value to decimal using Bash, you can use either the printf
command or bc
. Here’s how to do it with printf
:
printf "%d\n" 0x3000
This will output the decimal value corresponding to 0x3000
.
Alternatively, using bc
:
echo "ibase=16; 3000" | bc
This interprets 3000
as a hexadecimal value (base 16) and converts it to decimal.
In both cases, the result will be 12288
.