1、小于10的数实现自动补零
num_=$(printf "%02d" num)
2、十进制转十六进制
printf "%X\n" 255
FF
3、十六进制转十进制
echo $((0XFF))
255
VERSION=4.01.39
YEAR=23
MONTH=11
DAY=9
VERSION_NUM=`echo ${VERSION} | awk -F"." '{print $1$2$3}'`
#echo ${VERSION_NUM}
VERSION_NUM_HEX=`printf "%X" ${VERSION_NUM}`
#echo ${VERSION_NUM_HEX}
#echo ${VERSION_NUM_HEX:0:2}
#echo ${VERSION_NUM_HEX:0-2:2}
F181_Ver_1=`echo ${VERSION_NUM_HEX:0:2}`
F181_Ver_2=`echo ${VERSION_NUM_HEX:0-2:2}`
F181_Ver_3=`printf "%02X" ${YEAR}`
F181_Ver_4=`printf "%02X" ${MONTH}`
F181_Ver_5=`printf "%02X" ${DAY}`
F181_Ver={0x${F181_Ver_1},0x${F181_Ver_2},0x${F181_Ver_3},0x${F181_Ver_4},0x${F181_Ver_5},0x01}
echo ${F181_Ver}
网友评论