I do not see the test command in the IF loop...
so in case I need to check this for two files wat needs to be done ?Is the below code correct ??
--------------------------
#!/bin/csh
if ($#argv == 1) then
echo "Begin moving files"
mv file1 /file/file1$1
mv file2 /file/file2$1
mv file3 /file/file3$1
echo "Files Moved Successfully"
(if [ -s file1 && -s file2]; then
(uuencode /file/file1$1 file1$1; uuencode /file/file2$1 file2$1) |mailx -s "Report" alias@mymail.com
else
echo "file1$1 is empty" |uuencode /file/file2$1 file2$1 |mailx -s "Report" alias@mymail.com)
else
echo "Enter date suffix for the filename in the format mmmddyy"
endif
#
--------------------------
Main Topics
Browse All Topics





by: RBEIMSPosted on 2009-08-07 at 11:15:14ID: 25045492
You can use the "test" command to do this:
test -s file
returns TRUE if file exists and has a size bigger than 0
In bash you can use test expressions right inside the if statement, like this
if [ -s file ]; then
do_something;
else do_something
fi