Re: [SLUG] whats the best way?

From: iware@tampabay.rr.com
Date: Tue Jul 31 2001 - 10:04:43 EDT


Mike,

I usually test for the existance using:

if [ -f $file ]
then
   echo "file exists"
fi

other variations of the test are

 -r to see if it is readable
 -x to see if it is executable

and then of course the all important ! to check for non-existance, e.g.

if [ ! -f $file ]
then
  echo "file does not exist"
fi

Thanks,

Ian

>
> There are lots of ways to verify a file exists before acting on it. What is
> the cleanest and most efficient way to verify the existence of a file in a
> directory, from a script run from cron?
>
> my example: ls <file> && <execute program>
>
> Is there a better way?
>
> Michael C. Rock
>



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 17:24:32 EDT