bash newbie : no such file or directory problem
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 ]
then
echo "Didn't get directory or time parameters for deletion"
exit 1
fi
if [ ! -e $DIR ]
then
echo "Directory doesn't exist"
exit 1
fi
find $DIR -atime +$DTIME -type f -exec rm -f {} \;
exit 0
--
Rory Campbell-Lange
<rory@campbell-lange.net>
<www.campbell-lange.net>
--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: