Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Apr 2007 20:11:59 +0200
From:      deeptech71@gmail.com
To:        Pieter de Goeje <pieter@degoeje.nl>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: rm --clear-directory /home/me/another_dir
Message-ID:  <461D24EF.2050507@gmail.com>
In-Reply-To: <200704111849.08117.pieter@degoeje.nl>
References:  <461D0614.2060709@gmail.com> <200704111849.08117.pieter@degoeje.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
Pieter de Goeje wrote:
> On Wednesday 11 April 2007, deeptech71@gmail.com wrote:
>> Is there a way to clear a directory with such a command (keeping the owner
>> and permissions of the folder)?
>>
>> Yes there are the obvious ones:
>> cd /home/me/another_dir && rm *
>> rm /home/me/another_dir/* // if cant traverse here
>>
>> But something that doesn't rely on the shell.
> cd /some/dir && find . -delete
> 
> Cheers, Pieter
> 

Well, IMO, for aesthetical and logical purposes, /some/dir should point to the 
directory, and /some/dir/ should point to the inside of the directory (as in 
copy INTO or FROM). So:

# cp /one /two/    // this copies dir one into dir two, so there will be a dir 
named /one/two after this command

# cp /one/ /two/
==> Do you want to recursively overwrite contents of dir /two with the content 
of dir /one ? [n] y

# cp /one /two
==> Do you want to recursively overwrite /two with /one ? [n] y

# cp /one/ /two
cp: error - overwrite a dir with some other contents? WTF?

oh and of course:
rm -R /dir    // removes dir
rm -R /dir/    // clears dir


How hard will it be to convince the developers to swich to this scheme? since 
all scripts will have to be reworked...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?461D24EF.2050507>