作者;javalee
代码:
#! /bin/ksh
print 转换进制:
if [[ -z $1 || $1 == [a-zA-Z]* || $# > 1 ]]
then
cat <Usage:cn number[Enter]
cn 2#number for binary style
cn 16#number for hex style
cn number for stand style
info
exit
fi
integer -i10 value=$1
print ": \t $value"D""
typeset -i16 value
print ": \t $value"H""|sed 's/16#//'
typeset -i2 value
v2=$(print $value|sed 's/2#//')
integer len=${#v2}
((n=8-$len))
v=$(echo $(perl -e "print 0 x $n")$v2)
阅读(1045) | 评论(0) | 转发(0) |