Re: bash newbie : no such file or directory problem
On Wed, 3 Apr 2002 09:44:30 +0000
Rory Campbell-Lange <rory@campbell-lange.net> 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
You could use 'find' for this job:
This command delete all files that are older than 4 days in the /share directory:
find /share -type f ! -atime -4 -exec rm '{}' ';'
This one would delete the directorys if they are empty and older than 4 days:
find . -type f ! -atime -4 -exec rmdir '{}' ';'
Take a look into the manpages of find. its "mighty".
ciao
Walde
--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: