f() {
  local ip=$1
  local cidr=$2
  echo $ip/$cidr
  local n=$(echo $ip | tr '.' \\n | while read -r i; do
    echo "obase=2; =10; $i" | bc | xargs printf %08d
  done | sed -e "s/^[0-9]{$cidr}//g" | wc -c)
  echo $((2**n-2))
}

f 10.0.1.0 24 #シェル芸