Total of lines w/out header and footer incude for a file

I am trying to get a total number of tapes w/out headers or footers in a ERV file and append it to the file. For some reason I cannot get it to work. Any ideas?

#!/bin/sh
dat=`date +"%b%d_%Y"`
+ date +%b%d_%Y
dat=Nov16_2006
tapemgr="/export/home/legato/tapemgr/rpts"
tapemgr=/export/home/legato/tapemgr/rpts
ERVTAPE_RET="$tapemgr/returns/ervtape_ret.$dat"
ERVTAPE_RET=/export/home/legato/tapemgr/rpts/returns/ervtape_ret.Nov16_2006
tmpct=$tapemgr/tmp/tmptct.out
tmpct=/export/home/legato/tapemgr/rpts/tmp/tmptct.out
cat /dev/null > $tmpct
+ cat /dev/null
#rm $rpt/.out $rpt/.rpt

######## Run Report for Return Tapes
echo "\nERV: Please return the following list of IP Tapes for the BUR Group - STK9310-TSM Library\n" > $ERVTAPE_RET
+ echo \nERV: Please return the following list of IP Tapes for the BUR Group - STK9310-TSM Library\n
mminfo -r volume,pool,location,volretent -q location=ERV| grep expired | wc -l >tmp.out
+ mminfo -r volume,pool,location,volretent -q location=ERV
+ wc -l
+ grep expired
mminfo -r volume,pool,location,volretent -q location=ERV| grep expired >> $ERVTAPE_RET
+ grep expired
+ mminfo -r volume,pool,location,volretent -q location=ERV
sed -n '$=' $ERVTAPE_RET ; echo "Total Tapes Return Requested ..." >>tmp.out $ERVTAPE_RET
+ sed -n $= /export/home/legato/tapemgr/rpts/returns/ervtape_ret.Nov16_2006
7
+ echo Total Tapes Return Requested ... /export/home/legato/tapemgr/rpts/returns/ervtape_ret.Nov16_2006
cut -c1-8 $ERVTAPE_RET > erv.cutout
+ cut -c1-8 /export/home/legato/tapemgr/rpts/returns/ervtape_ret.Nov16_2006

## Send Email to request tape returned

Incorrect forum. I'll move this thread.

Cheers
ZB