Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] MacOS - How to find large files from Terminal recursively
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter
February 26, 2019 11:16 PM
Since I had to clean up my NAS, I had to go find the largests file on a particular directory and its sub-directories.
There are some tools for that, but they either do not work on a network share (Spotlight) or they spit out directories as well (du).
So after some searching and tinkering I came up with this:
sudo find -x <directory> -type f -size +<size>
Where <directory> can be any path, and size is done in the format: 1G (for > 1Gb), 2G, etc.
So as an example, find all files larger than 4Gb (mind you: it is the 1024 kind!) on /Volumes/MyNASShare
sudo find -x /Volumes/MyNASShare -type f -size +4G
Hope it is of use to someone
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter
March 3, 2019 1:34 AM
Little addon to this; say you want to find files bigger than 4 Gb and older than 7 days, we can use the same format and add "-mtime +7", like so:
sudo find -x /Directory/To/Search/ -type f -size +4G -mtime +7