Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'What empty trash does vs. rm' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
What empty trash does vs. rm
Authored by: scooby509 on Jul 26, '09 01:28:20PM
I haven't seen it documented, but there's not a whole lot the Finder needs to do.

The rm command calls unlink which is the normal way of deleting files in Unix. Source of rm is here, do a search for unlink(f) to see where unlink is called.

The unlink library call passes this request down to whatever file system you're using, and that's where all the complex stuff of managing various inodes and btrees and whatnot happens. So using Unix commands to delete stuff should not corrupt your file system. (Though it is possible, the -d option to rm is one way.)

Now, there is stuff like file associations and other stuff the Finder could take care of any time an app is installed or deleted. In cases where this is vital, developers usually release installer packages to make sure it happens. But most of the time, apps have everything they absolutely need stashed away in their app bundle. Generally, with that kind of stuff it's nice to have it tidied up, but not vital. And obviously the Finder doesn't attempt to clean up preferences or anything like that that litters your home directory.

One thing that did occur to me was that maybe the Finder tries to prevent you from deleting part of a package. So I did a little test: (Adjust that number if you have a slower or faster computer, and beware that this creates a ton of little files.)

for (( i = 0; i < 10000; i = i + 1 )); do echo "foo" > $i; done

Now, I know that rm -r will, if interrupted, leave with half its contents deleted. As it turns out, the Finder (as of 10.5.7) will do the same thing.

So if the Finder is slower, my guess is that it is being more careful about scanning for potential problems (rm -r will just throw up an error as it goes) and displaying a pretty progress bar.

My verdict: unless you're deleting some apps or preference panes or stuff like that, just use the script. Even if you do delete an app, there's no reason it should hose your system, and the Finder doesn't give much more of a guarantee anyway.

Reply to This | # ]