for full in $( ls -1 c*/*.sgm ) do echo "\nediting $x: \n" echo ${full} | cut -d/ -f2 | read x for dir in $(echo ${full} | cut -d/ -f1) do cd ${dir} echo "sed -f fawscr $x > /tmp/$x" sed -f ../fawscr $x > /tmp/$x if test -s /tmp/$x then cmp -s $x /tmp/$x && echo "file not changed: ";\ cp /tmp/$x $x; echo "done" else echo "Sed produced an empty file." fi cd .. done done echo "\nall done"