[comp.unix.questions] cleaning a directory

merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) (03/15/89)

In article <871@Portia.Stanford.EDU>, karish@forel (Chuck Karish) writes:
| Great, another feature!  How about using an alias instead:
| 
| 	alias rmall 'ls -f | xargs rm -f'
| 
| This avoids the overhead of sorting the names in the directory.
| It also suppresses those annoying queries from rm.

If the intent was to clean out a directory (and the directory itself
can be sacrificed and recreated), why not let 'rm' locate the files
itself, as in:

   $deadmeat=`pwd`
   cd /
   rm -rf $deadmeat
   mkdir $deadmeat
   chmod $someprotection $deadmeat

No big deal.  No passing of arguments to rm, and no need to worry
about .* files and files containing spaces and returns (yup, it's
pathological, but I worry sometimes...).

A certified UN*X Guru (Guru card #777)...
-- 
Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095
on contract to BiiN (for now :-), Hillsboro, Oregon, USA.
ARPA: <@intel-iwarp.arpa:merlyn@intelob> (fastest!)
MX-Internet: <merlyn@intelob.intel.com> UUCP: ...[!uunet]!tektronix!biin!merlyn
Standard disclaimer: I *am* my employer!
Cute quote: "Welcome to Oregon... home of the California Raisins!"

rwl@uvacs.cs.Virginia.EDU (Ray Lubinsky) (03/26/89)

In article <4218@omepd.UUCP>, merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) writes:
>    $deadmeat=`pwd`
>    cd /
>    rm -rf $deadmeat
>    mkdir $deadmeat
>    chmod $someprotection $deadmeat
> 
> No big deal.  No passing of arguments to rm, and no need to worry
> about .* files and files containing spaces and returns (yup, it's
> pathological, but I worry sometimes...).

Another advantage to your method is that sometimes directory files get quite
large if they have had a large number of filenames within them.  Removing and
recreating the directory itself will let you pare down the directory file to
the smallest size possible.

x

-- 
| Ray Lubinsky                         rwl@trinity.cs.virginia.edu (Internet) |
|                                      rwl@virginia                  (BITnet) |
| Department of Computer Science,      ...!uunet!virginia!uvacs!rwl    (UUCP) |
| University of Virginia               (804) 979-6188                 (voice) |