check for file existence

Hello

I am having a requirement like if there is no file in the directory then i need a message to pop on after the execution of the script.

My script basically does for File in `ls -t $DIRECTORY | tail -1`;
if there is no file the DIRECTORY then the script is simply exiting with out giving any message but i want a message to pop on the screen with non-zero exit code.

Thanks

There is a shell scripting subforum here - this one here is specific for AIX.

I am looking for 'regular' files with the grep, and seeing a file count

> ls -l ./raw | grep "^-" | wc -l
45
> ls -l ./raw1 | grep "^-" | wc -l
0

Now, take a look at the following two examples and commands

> numf=$(ls -l ./raw | grep "^-" | wc -l)
> if [ $numf -gt 0 ] ; then echo "Files Present"; else  echo "No Files"; fi
Files Present
> numf=$(ls -l ./raw1 | grep "^-" | wc -l)
> if [ $numf -gt 0 ] ; then echo "Files Present"; else  echo "No Files"; fi
No Files