difference between -e and -f option in "if statement" in korn



All,

What is the difference between the followig two chunks of code:

if [ -e /var/mail/root ] # Here /var/mail/root is
just an example file.....it can be anything.
then
echo true
else
echo false
fi




if [ -f /var/mail/root ]
then
echo true
else
echo false
fi

Actually, I was using the first one ( -e ) in my shell script to
check the existance of some files and it was working perfectly fine.
Suddenly after couple of days same script gives me error this error:

../myscript.ksh[618]test: agrument expected

Here 618 is the line number where I am using if statement. The script
gives me line numbers everytime it finds
" if statement " with -e option.

After spending some time I realized that -f will also do the same
task. So I changed everything from -e to -f.

But I am curious about this behavior .....it was working perfectly
fine before and suddenly these errors came......

Any ideas??

Regards,
RB

.



Relevant Pages