Skip to Content

Fast Hex to Decimal in Bash

Posted on One min read

I needed too turn some hexidecimal values into decimal in a bash script and found a real easy way too do it. The following is a very short bash script demostrating how too turn the hexidecimal string “deadbeefcafe” into it’s equivalent decimal value of “244837814094590”.

#!/bin/bash

INPUT="deadbeefcafe"
OUTPUT=$((0x${INPUT}))

echo $OUTPUT