Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: deleting unused folders



Robert Everson schrieb:

> After running a few more tests, I have seen that it does traverse into
> the lower directories, but only if the main directory doesn't trigger
> the -nouser action.  This is still not what I expected it to do, but it
> does seem to behave exactly like my test server, so I guess I'll have to
> deal with it, unless anyone else has a nugget of information that they
> would like to share.

Hi Robert,

take a look at the "-depth" primary of the find utility.

find /Users -depth +1 -type d -nouser -print

will find all folders (-type d) belonging to no known users (-nouser) at
the first level (-depth +1) after "/Users" and print them to screen.

If you want delete them and you are courageously, try something other
like _-print_:

find -d -P /Users -depth +1 -type d -nouser -exec rm -rf {} \;

_-rf_ is dangerous, so its better to built a list with folders of
unknown users, and delete them in three steps:

1. finding folders to work on
2. delete files in there recursively
3. delete directories recursively

Something like that will do (but check!):


for i in `find /Users -depth +1 -type d -nouser -print`; do
        find -d -P  $i  ! -type d  -exec rm {} +
        find -d -P  $i    -type d  -exec rmdir {} +
done

_{}_ will be replaced with found files, and the _+_ let find push the
files to _rm_ like _xargs_ (man xargs). The "! -type d" will also find
special files like links, sockets etc., if you don't delete them the
following _rmdir_ will sometimes fail if there such a file (dir not empty).

But double check this for your own, I'm typed this directly from my head
and I didn't worked with the _-nouser_ statement yet.

-- 
Timm
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macos-x-server mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/macos-x-server/email@hidden

This email sent to email@hidden

References: 
 >deleting unused folders (From: Robert Everson <email@hidden>)
 >Re: deleting unused folders (From: Robert Everson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.