1. Convert hex byte to decimal format
a=0x30
b=`printf %i $a`
echo $b
2. Convert ASCII code byte to the char.
a=0x61
b=`printf %i $a | awk '{printf("%c\n", $1)}'`
echo $b
3. Convert the char to ASCII code byte
a="abcde"
a_len=`expr length "$a"`
for (( i=1; i<=$a_len; i=i+1 ))
do
index=$i
each_char=`expr substr $a $i 1`
each_char_ascii=`printf %s $each_char | od -A n -t x1 | tr -d ' '`
echo "$each_char_ascii "
done
4.
沒有留言:
張貼留言