#!/usr/bin/ksh for month in 05; do files="" output_file="$month_test" for object in *; do if [[ -f $object ]] && [[ $object != "core" ]]; then newfile=$(grep -l "$month/" $object) if [[ $newfile != "" ]]; then newgif=${newfile%dat}gif case $month in 05) cp $newfile ../may2000/$newfile cp "plot1/$newgif" "../may2000/plot1/$newgif" cp "plot2/$newgif" "../may2000/plot2/$newgif";; 06) cp $newfile ../june2000/$newfile cp "plot1/$newgif" "../june2000/plot1/$newgif" cp "plot2/$newgif" "../june2000/plot2/$newgif";; 07) cp $newfile ../july2000/$newfile cp "plot1/$newgif" "../july2000/plot1/$newgif" cp "plot2/$newgif" "../july2000/plot2/$newgif";; 08) cp $newfile ../august2000/$newfile cp "plot1/$newgif" "../august2000/plot1/$newgif" cp "plot2/$newgif" "../august2000/plot2/$newgif";; 09) cp $newfile ../september2000/$newfile cp "plot1/$newgif" "../september2000/plot1/$newgif" cp "plot2/$newgif" "../september2000/plot2/$newgif";; esac fi fi done print "$month: $files" done