Re: [SLUG] whats the best way?

From: Russell Hires (rhires@earthlink.net)
Date: Tue Jul 31 2001 - 20:40:06 EDT


This is usually the way I see most shell scripts work. If I go through my
/etc/init.d/ scripts, I see lots of
if [ -f $file ]
type stuff...

Russell
On Monday 30 July 2001 22:04, you wrote:
> 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:25:47 EDT