Site icon Web Niraj

Finding large files on Mac / Linux

I recently ran into a problem with disc space on my Mac, requiring me to find and delete large files to free up some space quickly. I found the following command (in Terminal) very useful to find large files of a given size in a given directory.

Syntax for Mac OS X / RedHat / CentOS / Fedora Linux

find {/path/to/directory/} -type f -size +{size-in-kb}k -exec ls -lh {} \; | awk '{ print $9 "/" $11 ": " $5 }'

Syntax for Debian / Ubuntu Linux

find {/path/to/directory} -type f -size +{file-size-in-kb}k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'

I used the following command to find files larger than 500MB in my Home directory on my Mac:

find {/Users/Niraj/} -type f -size +500000k -exec ls -lh {} \; | awk '{ print $9 "/" $11 ": " $5 }'

Exit mobile version