Can someone help me to convert a hexadecimal number to decimal number in a shell script?
E.g., I want to convert the hexadecimal number bfca3000
to decimal using a shell script. I basically want the difference of two hexadecimal numbers.
My code is:
var3=`echo "ibase=16; $var1" | bc`
var4=`echo "ibase=16; $var2" | bc`
var5=$(($var4-$var3)) # [Line 48]
When executing, I get this error:
Line 48: -: syntax error: operand expected (error token is "-")
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…