find command
To list files that were changed in the last day, sorted by size, using Apple’s Terminal, or any Unix / Linux bash shell:
> sudo find / -type f -mtime -1 -print0 k
| xargs -0 du -sk | sort -nr
(thanks mynamewasgone!)
Command breakdown
- sudo
- run in superuser mode - allows you to reach hidden system folders (if that's what you need). You'll be asked for your password
- find /
- use the powerful find command, starting from the root of the computer - in other words, search everywhere (which may not be a good idea if you are connected to a network or have a massive hard disk connected to your machine)
- -type f
- only look for files...
- -mtime -1
- ...modified less than a day ago
- -print0
- when files are found, spit them out in a list with a NULL at the end instead of a new line - this helps with the next step
- |
- pass the list generated by find to the next command...
- xargs -0
- ...which is xargs, used to take a list of results and pass them on. The -0 is telling xargs to use NULL as the separator
- du -sk
- use du to show how much space the files take, in kilobytes
- |
- pass the list generated by find to the next command...
- sort -nr
- ...which sorts the list in reverse numerical order using sort
Find -exec is slow
Originally I did everything within find, using the -exec flag.
$ sudo find / -type f -mtime -1 -exec du -sk {} ; | sort -nr
But as mynamewasgone pointed out, find -exec is slow