Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!cuuxb!dlm
From: dlm@cuuxb.ATT.COM (Dennis L. Mumaugh)
Newsgroups: comp.unix.wizards
Subject: Re: `rm -rf dir' fails with Directory not empty
Summary: you are working with invisible files
Message-ID: <1430@cuuxb.ATT.COM>
Date: 10 Dec 87 15:49:33 GMT
References: <125@Edvax.UUCP>
Reply-To: dlm@cuuxb.UUCP (Dennis L. Mumaugh)
Organization: ATT Data Systems Group, Lisle, Ill.
Lines: 46

In article <125@Edvax.UUCP> edward@comp.vuw.ac.nz (Edward Wilkinson) writes:
>Sometimes, when I do a `rm -rf dir', every so often rm complains about
>a `directory  not empty'  error  somewhere down the   hierarchy.  This
>propagates to the higher levels & leaves an  empty directory structure
>behind. Another `rm -rf dir' results in the same, even  when  executed
>as  super-user. I  once  tried  using  unlink(2) with  less  than best
>results: as me, it didn't work, while as superuser, the following fsck
>fell over. We then  had to do a restore,  which left us  with the  dud
>`empty' directory again.
>
>Does anyone know what I'm doing wrong? We run Ultrix 1.2 on a Vax  750
>if it's any use. Any ideas would be most gratefully received.
>

I haven't seen any response posted and since this is from Down Under
the person may not get any other answer so here goes:

One of the more nasty habits of programs is to  use  a  so-called
dot  file.  This  is a file beginning with a period.  The purpose
of these files is to  save  information  and  at  the  same  time
suppress any evidence of their existence.  This is because of the
fact there are ALWAYS (or almost always) two such  files  in  any
directory  ("."  and "..").  To avoid always see those files with
an ls command and using their name in a global (as in rm  *)  the
software in the shell and ls ignore all file names beginning with
period. (Ls -la will change this).

The problem with the dot files is that  when  it  comes  time  to
remove  the  directory  (with  rmdir  or  rm  -rf) it appears the
irectory is empty but it really isn't and thus the program balks.

Solution: 

cd to the directory that can't be removed and do an 
	ls -la
You ought to see some files.  Then do a 
	rm -f .*
This is okay since rm won't remove directories.  Then continue  as
previously.

Why does rm -rf bitch?  Because it does a fork and then execs the
command  rm  -rf  *  (which  won't pick up the dot files).  After
which it will do an rmdir * (to cleanup the sub-directories).
-- 
=Dennis L. Mumaugh
 Lisle, IL       ...!{attunix,ihnp4,cbosgd,lll-crg}!cuuxb!dlm