If you need a large sub tree gone, mv dir .old-dir && rm -r .old-dir & works pretty well. Faster even than an optimized parallel unlinker.
Why would running mv before rm be faster? On what file systems is this true?
The fastest rm command and one of the fastest cp commands
21–30 of 83 posts
Re: The fastest rm command and one of the fastest cp commands
#22Earlier quoted context omitted.
Slight tangent: why do you need to delete Xcode so often? (I don't really develop on Mac, mostly on Linux.)
Not OP, but disk space maybe? It's pretty big. $ du -Ash Xcode.app 22G Xcode.app
> $ du -Ash Xcode.app
> 22G Xcode.app
My installation of Xcode only takes up 3.6G and is still fully operational.
As a developer of both desktop and mobile apps, I discovered some time ago that I could delete most, if not all, of the Xcode simulators that I don’t use without affecting the functionality of the IDE. The software is smart enough to download additional assets when you attempt to launch one of the simulators. I believe that, by default, Xcode comes with simulators for the latest versions of iOS, iPad OS, Watch OS, and Apple TV, sometimes including two or three versions for each platform.
I think this is the reason why your installation weights 22G.
Re: The fastest rm command and one of the fastest cp commands
#23If you need a large sub tree gone, mv dir .old-dir && rm -r .old-dir & works pretty well. Faster even than an optimized parallel unlinker.
This reminds me of a similar trick to speed up deallocations by moving them to a new thread: https://abramov.io/rust-dropping-things-in-another-thread
Re: The fastest rm command and one of the fastest cp commands
#24Earlier quoted context omitted.
Amusingly it’s basically how most GUI desktops “delete” stuff, they just put a confirmation in place of the &&
I don't think any GUI move items before a confirmation, so I don't see the link at all.
Re: The fastest rm command and one of the fastest cp commands
#25Always something interesting to learn at the margins
Re: The fastest rm command and one of the fastest cp commands
#26If you need a large sub tree gone, mv dir .old-dir && rm -r .old-dir & works pretty well. Faster even than an optimized parallel unlinker.
Re: The fastest rm command and one of the fastest cp commands
#27Earlier quoted context omitted.
Why would running mv before rm be faster? On what file systems is this true?
The idea is to rename it so that you don't have to wait for it to be deleted. You can let the deletion run in the background once it has been moved out of the way.
Re: The fastest rm command and one of the fastest cp commands
#28Earlier quoted context omitted.
I don't think any GUI move items before a confirmation, so I don't see the link at all.
They almost universally do! They move stuff to a designated trash or recycle bin or whatever to stage for final deletion when you commit to it.
Once the file is in the recycle bin, it will probably be months before final deletion happens, and windows will not ask before doing so.
Re: The fastest rm command and one of the fastest cp commands
#29Hmm. I appreciate the cute name for the project but I tested this on my machine (a Mac) and the results were not very impressive. I sacrificed a few of my SSD cycles to test how this is on deleting Xcode (for those unaware, it's a 11 GB mess of several hundred thousand files of varying sizes). Here are the results: $ time rm -rf Xcode.app real 0m39.850s user 0m0.429s sys 0m29.153s $ time rmz Xcode.app real 0m36.476s…
Slight tangent: why do you need to delete Xcode so often? (I don't really develop on Mac, mostly on Linux.)