At 08:28 AM 3/21/2001 -0700, Rusty Carruth wrote:
>WHERE=/foo/to/delete
>cd $WHERE
>if ( `pwd` != $WHERE )
>         echo "Cannot change to $WHERE, goodbye" ; exit 1
>endif

Since it looks like we are trading shell tricks try this one :)
This only works in bash or where a bash-like test syntax works.
WHERE=/foo/to/delete
if [ -x $WHERE ]; then
         echo "Cannot change to $WHERE"
         exit 1
fi

This will test if the directory exists and if you have execution
permissions for the directory, which are necessary to execute
the cd into said directory.  If where exists, but you can't cd into
it to delete things from it, then the csh script above may have
bad side effects.  If you just need to test for the existence of
the directory in bash, change the -x test in the if statement to a
-d.
--
Matthew Micene
Systems Development Manager
Express Search Inc.
www.ExpressSearch.com


Reply via email to