convert first column from hex to decimal using awk

2 linux shell awk hex sed

I have a log file which contains logs time stamp in Hexadecimal in column one and then log text in rest of the columns.For example:

B60C0056: aaa1 bb1 ccc1 ddd1 eee1 fff
B60C0056: aaa2 bb2 ccc2 ddd2 eee2 fff
B60C0057: aaa3 bb3 ccc3 ddd3 eee3 fff
B60C0058: aaa4 bb4 ccc4 ddd4 eee4 fff
B60C0059: aaa5 bb5 ccc5 ddd5 eee5 fff
Run Code Online (Sandbox Code Playgroud)

I need to convert the first column to decimal and I am using the following way to do so,but don't know how to implement this for the whole file.

while read line
do
echo -e "$line"|awk '{print $1,$2,$3,$4,$5,$6}'
done <temp
Run Code Online (Sandbox Code Playgroud)

But how to convert $1 to the decimal value?

echo "ibase=16; `awk '{print $1}'`" | bc
Run Code Online (Sandbox Code Playgroud)

anu*_*ava 5

awk's strtonum function can take care of that:

awk 'BEGIN{FS=OFS=":"} {$1=strtonum("0x" $1)} 1' file
3054239830: aaa1 bb1 ccc1 ddd1 eee1 fff
3054239830: aaa2 bb2 ccc2 ddd2 eee2 fff
3054239831: aaa3 bb3 ccc3 ddd3 eee3 fff
3054239832: aaa4 bb4 ccc4 ddd4 eee4 fff
3054239833: aaa5 bb5 ccc5 ddd5 eee5 fff
Run Code Online (Sandbox Code Playgroud)