Rm -r -f does not delete internal folder

I have large projects and some scripts to compile them. I can't add all the code here, so I'll try to simplify the problem: in the cleanup part, I need to clear a named folder directory

that contains another named directory innerDir

. I have a bash command to clean up directory

:

clean:
    rm -r -f directory

      

When the directory is a folder that I created with mkdir -p

in advance. When I clean I get this error:

rm: cannot remove 'directory': Directory not empty

      

But when I try to enter directory

, I see that it is empty. So for debugging purposes, I modified my cleanup part:

rm -r -f directory/*
find directory
rmdir directory                    

      

(it should do the same, but here I also get a chance to see if all content has actually been removed directory

).
Now I am getting this error:

find: 'directory/innerDir': Permission denied  

      

There are two things that are unclear to me here:
(1). innerDir

was created using the makedir -p

front wedges part without any changes to the permissions of this in the code later. Why don't I have permission to delete?
(2). If I try to clean up again - cleanup succeeded and I have no permission issues. So, if I got a permission error for the first time, I tried to delete it, why don't I get it a second time?

+3


source to share


1 answer


If your permissions are valid in the directory tree, rm -fr directory

should work.

If you don't have read access to innerDir, is it possible (possibly depending on the running processes) that something is written to innerDir, but the file is cleared after the directory becomes free?



Can you provide examples of permissions, ownership, and some area of โ€‹โ€‹operations performed between each step?

Could you rename the parent folder at runtime and / or lock its permissions so that other users or processes cannot change?

+1


source







All Articles