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
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