如何实现Hex和Dec转换
使用下面两个脚本即可:
1.Dec转Hex
hex()
{
typeset -i HeX
((HeX=16#0))
while [ $# != 0 ]
do
((HeX=$1))
print -n "0x${HeX#16#}"
shift
done
print -
}
2.Hex转Dec
dec()
{
((DeC=0))
while [ $# != 0 ]
do
((DeC=16#${1#0x}))
print -n "${Dec}"
shift
done
print -
}