Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Sep 2002 10:48:21 -0400 (EDT)
From:      John Mills <jmmills@telocity.com>
To:        "Riley J. McIntire" <rileyjmc@pacbell.net>
Cc:        John Mills <john.m.mills@alum.mit.edu>, Beech Rintoul <akbeech@sinbad.net>, FreeBSD Questions <freebsd-questions@FreeBSD.ORG>
Subject:   RE: Can't delete a directory
Message-ID:  <Pine.LNX.4.21.0209121012530.4243-100000@otter.mills-atl.com>
In-Reply-To: <HEEELMCBPANKADCOBOFPGECLGFAA.rileyjmc@pacbell.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Riley, All-

Here's another suicidal approach:

On Wed, 11 Sep 2002, Riley J. McIntire wrote:

after I babbled:
> > How about:
> >   [ ]$ rm -rf <root_of_destruction> 

> root@wimp:obj# rm -rf usr/
> rm: usr/fsck_msdosfs: Directory not empty
> rm: usr/: Directory not empty
> root@wimp:obj#

Sorry - I came in late on this. Even as root! Is this behavior limited to
DOS directories?

You could try a script or alias to the general effect of:

-+-+-+-+-+-+-+-+-+-+-+-+- slashwrist -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#!/bin/sh
# sorry - I'm a bash weenie.
if [ $# -lt 1 ]
then
 echo "usage: slashwrist <root_of_destruction>"
 echo " and be _really_ careful, Boss!"
 exit

else
 for FILENAME in `find $1 ! -type d -print`
 do
# consider interactive use here: 'rm -i $FILENAME'
  echo "Removing "$FILENAME
  rm -f $FILENAME
 done
 echo "Removing directories below "$1
 rm -rf $1
fi
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

You may have to run that as root, too, depending on permissions associated
with DOS directories.

DISCLAIMERS:

1) There is pretty much no limit to the damage you could do
your system with this script.

2) I just typed that out by way of example, and tried it only once in
FreeBSD. It may well contain errors, or constructs that work differently
than I expected. If you try it, _first_ comment out the 'rm' lines, then
run it and carefully read the list of files which would have gone to the
bit-bucket before you fire off a 'killer' version!

If you get the idea I'm a bit cautious about this, you get full credit on 
the quiz. I would almost prefer to do it manually.

I once wiped out my Linux box's '/var' in a moment of emotion with a
simple 'rm' at the wrong spot - the emotions which followed were _much_
stronger!! Recovery took quite a while and ultimately a lot of rebuilding.

YMMdefinitelyV!
 - John Mills



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.21.0209121012530.4243-100000>