Find files larger than X and delete them in Mac OS/Unix terminal

Another terminal oneliner I've just used to delete files larger than 10mb.

Read this tutorial carefully!
The first command will permanently delete all files larger than 10mb from the current folder and subfolders!

So if you need to delete some files larger than X mb on your Mac or some unix server, here is the simple oneliner to do it, in this example we're looking for files larger than 10mb in current folder (and subfolders, because find command is recursive) and delete them:

find ./ -size +10000000c -exec rm {} ;

And to be sure that you'll be deleting the right files, you can first list them like this:

find ./ -size +10000000c -exec ls -la {} ;

Comments

Thank you!
Was looking for this... very helpful.

Lapog 1. Nov 2010 at 4:42 PM

Wow. I accidently ran this thinking it would prompt me first. Whoops. Now I deleted a lot of files and they aren't in the trash bin. Uh oh!

George 28. Apr 2011 at 7:40 AM

awesome, works in linux too

droope 8. Jun 2011 at 4:01 PM

thanks!!

aphex13 22. Jun 2011 at 10:03 PM

I think you should put a big warning before your rm command that if you type this and hit return, EVERY file larger than 10MB will be deleted FOREVER.

Jim Coleman 24. Jun 2011 at 7:41 PM

You shouldn't cut and paste commands without reading them first. Sometimes you have to learn the hard way.

Jon 1. Mar 2012 at 11:53 AM Reply to: Jim Coleman

Thanks a lot, I didn't know about this "-size" option.
To return files smaller than Y, just use minus (-) instead of plus (+).
Ex: find ./ -size +10000000c -30000000c -exec ls -la {} \;

I'm using find on linux but on mac I use a tool called "toucan search" (I got it on the mac app store), it's like find but with a gui so it's easier to use. So if I want to do some clean up I just look for * (the wildcard that means "everything") then I sort the files by size and delete the big files I don't need anymore (.dmg I forgot to delete, etc).

Jackie K. 19. Aug 2011 at 4:38 AM

what if I want to delete all files in a directory that re 1kb in size. Can someone please let me know the Terminal command?

Manoj 3. Mar 2013 at 10:30 PM

Leave a comment

*
Leave your e-mail if you would like to get reply from me. Your e-mail will not be shown on my web page nor will I use it for anything other than replying to your question/comment.
**
Leave your website address if you want an extra link pointing to it ;)