Skip to Content

Fast Hex to Decimal in Bash

Posted on One min read

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

#!/bin/bash

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

echo $OUTPUT