#!/bin/sh
#
FILPAT=$1
FILS=`ls $FILPAT`
echo $FILS
touch tmptmp
rm tmptmp

for FIL in $FILS ; do
#  sed -f repl.sed ${FIL} > tmptmp
#  sed -f replh.sed ${FIL} > tmptmp
  grep ostream_iterator ${FIL} > tmptmp
  if [ -s tmptmp ] ; then
#	echo "replacing?"
	rm tmptmp
	grep '<iterator>' ${FIL} > tmptmp
	if [ -s tmptmp ] ; then
#		echo "skipping"
		rm tmptmp
	else
#		echo "replacing."
		rm tmptmp
		sed -f ostream.sed ${FIL} > tmptmp
		mv tmptmp ${FIL}
	fi
  else
#	echo "skipping"
	rm tmptmp
  fi
done