#cat bconv
#!/bin/bash function char2dec { case $1 in b) echo "2" ;; o) echo "8" ;; d) echo "10";; x) echo "16";; *) echo $1 ;; esac } n=`echo $1 | tr [:lower:] [:upper:]` ib=`char2dec $2` ob=`char2dec $3` echo "obase=$ob;ibase=$ib;$n" | bc -l | tr [:upper:] [:lower:] #./bconv 1001100110111 b x
1337
No comments:
Post a Comment