mask2cdr 203 B

12345
  1. # Assumes there's no "255." after a non-255 byte in the mask
  2. x=${1##*255.}
  3. set -- 0^^^128^192^224^240^248^252^254^ $(( (${#1} - ${#x})*2 )) ${x%%.*}
  4. x=${1%%$3*}
  5. echo $(( $2 + (${#x}/4) ))