![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help wid C-script in tcsh | mahendrakamath | High Level Programming | 12 | 11-28-2007 01:12 PM |
| tcsh I can't get script to work :( | Fred Goldman | Shell Programming and Scripting | 8 | 11-12-2007 05:44 PM |
| help in tcsh | mahendrakamath | UNIX for Dummies Questions & Answers | 3 | 11-12-2007 04:05 PM |
| how to call a perl script from tcsh? | megastar | Shell Programming and Scripting | 1 | 10-22-2005 06:48 PM |
| tcsh | kartik | Shell Programming and Scripting | 1 | 10-20-2004 06:05 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Help me with this tcsh script.!!!!(Anbu)
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 Last edited by kumarsaravana_s; 03-12-2007 at 05:45 AM.. |
|
|||||
|
Quote:
CshTop10 Csh csh-whynot Quote:
Code:
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
Last edited by vgersh99; 03-09-2007 at 03:31 PM.. Reason: fixed the URL links with the vB Codes |
|
||||
|
Hi Anbu
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 |
|
||||
|
Code:
$ 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
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|