#!/bin/ksh -p
# Assuming that $1 is the input, output will be masked according to $2

IFS=" .
"

set -A address $1
set -A mask $2
output=""

IFS=" 
"
# There's a space after the first IFS quote up...


count=0
while (( $count < ${#address[*]} )) ; do

  output="${output}.$(( ${address[$count]} & ${mask[$count]} ))"
  count=$(( count + 1 ))

done

echo $output | sed 's/^.//'

#end script

