On Wed, Apr 03, 2002 at 09:44:30AM +0000, Rory Campbell-Lange wrote:
> I'm trying to construct an automated bash find->delete script to clear
> out 3 file share processing areas on our server.
>
> I call the script using the following sytax:
> ./deleter.sh /dir 5
> with the idea that all files in /dir and its subdirectories are deleted
> if they were last accessed more than 5 days ago.
>
> While the find line runs perfectly on the command line, the script
> works, but returns the following error:
>
> ./deleter.sh: 1: No such file or directory
>
> I'd be grateful for some help to track down the problem. Yes, my bash is
> installed in /bin/bash!
>
> Cheers
> Rory
>
> ----
>
> #!/bin/bash
> DIR=$1
> DTIME=$2
> if [ ! $DIR ] || [ ! $DTIME ] || [ $DTIME < 1 ]
^^ ??
You probably meant:
if [ ! "$DIR" ] || [ ! "$DTIME" ] || [ "$DTIME" -lt 1 ]
The quotes will ensure that it actually can check for missing
parameters. And '<' is used for redirecting input, not comparing...
PS: Have a look at tmpreaper - I suspect that most debian systems have
that installed. It has a plethora of options and should be able to do
what you want. Why write it yourself if somebody else has already?
HTH
--
Karl E. Jørgensen
karl@jorgensen.com
www.karl.jorgensen.com
Please study http://www.rfc855.org
Attachment:
pgptegx5o0guY.pgp
Description: PGP signature