echo "a36b"|awk 'BEGIN{ hextodec["a"]=10;hextodec["b"]=11;hextodec["c"]=12;hextodec["d"]=13
hextodec["e"]=14;hextodec["f"]=15;hextodec["0"]=0;hextodec["1"]=1;
hextodec["2"]=2;hextodec["3"]=3;hextodec["4"]=4;hextodec["5"]=5
hextodec["6"]=6;hextodec["7"]=7;hextodec["8"]=8;hextodec["9"]=9
}
{
string=tolower($0)
for(i=1;i<=length(string);i++)
{
c=substr(string,i,1)
if(c in hextodec)
result=result*16+hextodec[c]
else
{
print "不是合法的十六进制数"
exit 1
}
}
printf "%s 是十进制数%d\n" ,$0, result
} '