#! /bin/ksh -x

typeset -i RECORD=0
typeset FILE=''
typeset DEST='f1eurver.Drawer56'

> ${DEST}
AFPSplit -s f1eurver
afpdmp f1eurver \
| grep 'Medium Modification Cntl' \
| awk '{print $1}' \
| sed -e 's/^[\.]*//g' \
| while read RECORD
  do
    RECORD=RECORD-1
    FILE=$( print -- f1eurver.0*0${RECORD} )
    if afpdmp -d ${FILE} \
    | grep -q 'source drawer #[1|2]' 
    then
      dd < ${FILE} count=15 bs=1 > ${FILE}.$$
      od -j15 -h ${FILE} \
      | sed -e 's/^0000000  //g; /^0000008/d; /^0000010/d; s/^e101/e164/g; s/^e102/e141/g; s/ //g' \
      | dx >> ${FILE}.$$
      mv ${FILE}.$$ ${FILE}
    fi

  done

for FILE in f1eurver.0*
do
  cat ${FILE} >> ${DEST}
  rm ${FILE}
done

exit 0

####################### EOF #######################
