Help me with this tcsh script.!!!!

I need to write a tcsh script which would compare files in the two folders and then send me a mail saying which of the files are missing.For eg

1) I have this folder1 containing all the files which must land on folder2 on a daily basis.

2) If a file is present in folder1 but not in folder2,then a email must be sent to me saying which file is missing in folder2.

for instance,

Folder 1 has(it has some 103 files to be precise)

aaa
bbb
ccc
ddd
ccc
eee
fff

folder2 has(the same file name but with a daily time stamp attached to it.So need to remove this date portion and then compare the files in folder2 with files in folder1

aaa.03082007
bbb.03082007
ccc.03082007
ddd.03082007

So the script must inform me that eee and fff files are missing...

I want this whole process to be inside a loop and somewhat automated so that i dont have to run the script daily manually.

your help will be greatly appreciated....

Thanks
Kumar

cd /dir/folder1
for i in *
do
	if [ -f ./$i -a ! -f /dir1/folder2/${i}"."* ]; then
		echo "$i file not found"
	fi
done

dir1=$(ls directory1)
dir2=$(ls directory2)
for i in $dir1
do
$(echo $dir2 | grep -q $i)
[[ $? -ne 0 ]]&& echo $i
done

its easier to read using code tags

Don't use [t]csh for scripting. See:

    [CshTop10](http://www.grymoire.com/Unix/CshTop10.txt)
    [Csh](http://www.grymoire.com/Unix/Csh.html\#uh-0)
    [csh-whynot](http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/)
is_file()
{
    for f
    do
       [ -f "$f" ] && return
    done
    return 1
}

cd Directory1
for file in *
do
   is_file "Directory2/$file"* || printf "%s not found\n" "$file"
done

To run it regularly, put the script in a cron job.

i dont know but your seems to just display file not found all the time...

let me make myself more clear...

1st folder = /space/dwland/all_files/

Now,this folder has files like xxx.<file_name>,bbb.<file_name> and so on

2nd folder = /space/dwland/prodland/

now this folde has files like xxx.<file_name>.<date>,bbb.<file_name>.<date>, and so on..

I want to compare 1st folder with 2nd folder(-minus the date portion,for the file_names should be compared) and display the files which are not present in folder 2 but present in folder 1

$ ls ./folder1
aaa  bbb  ccc  ddd  eee  fff
$ ls ./folder2
aaa.03082007  bbb.03082007  ccc.03082007  ddd.03082007
$ cd folder1
$ for i in *
> do
>       if [ -f ./$i -a ! -f /dir1/folder2/${i}"."* ]; then
>               echo "$i"
>       fi
> done
eee
fff