Re: rmdir when directory is not empty

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chasecreek Systemhouse wrote:
On 12/20/05, kebbelj@xxxxxxxxxxxxxxxxxxxxxxx
<kebbelj@xxxxxxxxxxxxxxxxxxxxxxx> wrote:

In the GUI, I can trash a non-empty directory with a right-click and Move to Trash. What command line option would I use with rmdir to remove a non-empty directory?



The best way to nuke a directory is -

# Delete the files.
su - -c "find /path/to/dirName -type f -exec rm -f {} \;"

ACK!

$ rm -fr /path/to/dirName

is far safer. It won't work if there is a directory with
too many files in it, in which case the find will work.

But to do it as root! Man, not for the faint-hearted!

I rarely do anything as root. I've used

# rm -fr /path/to/dirName

before, but I've always, always, always looked away from the screen,
and then looked back, at least twice, carefully reading the
command.

I recall a shop where I worked for a while where we had a small
VAX running Mt. Xinu (UNIX tm backwards, means Xinu Is Not Unix).
The sys admin had no clue about security, so all users were
aliases of user 0 (IOW, everyone was root). We did marketing
research, and the people who built the questionnaires were
called "Wookies" (from Star Wars), which was an appropriate
term. About once a month or so one of them would want to delete
a study from the disc, and would mis-type

# rm /studies/s12345

as

# rm / studies/s12345
rm: cannot remove `studies/s12345': No such file or directory

After which

# ls /studies/s12345
bash: ls: command not found

(Actually, I think it was the cshell.)

# Delete the directory paths.
su - -c "rmdir -p /path/to/dirName"

HTH/Bill
--
WC -Sx- Jones | http://ccsh.us/ | Open Source Consulting


Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux