115

How can I make ls (or any other command) list only files bigger than a specific file size?

Johnny
  • 1,277
  • 2
  • 8
  • 8

3 Answers3

185

Use find and its -size flag.

To find files larger than 100MB:

find . -type f -size +100M

If you want the current dir only:

find . -maxdepth 1 -type f -size +100M
Drew Noakes
  • 2,137
  • 3
  • 18
  • 28
Nifle
  • 34,203
  • 26
  • 108
  • 137
  • 3
    If you need to pass the size in bytes, use `find . -type f -size +4096c ` (https://superuser.com/a/204571/111289) – ᴍᴇʜᴏᴠ Aug 08 '17 at 09:19
  • just to extend the answer: to get the number of files bigger than specified, pipe it to word count `find . -maxdepth 1 -type f -size +100M | wc` – B.Kocis Nov 09 '20 at 12:55
41

If you wish to see all files over 100M and to see where they are and what is their size try this:

find . -type f -size +100M -exec ls -lh {} \;
Ofir Zvik
  • 411
  • 4
  • 2
  • 1
    I think it would be easier to use printf parameter `-printf "%p %s"`. See: http://unixhelp.ed.ac.uk/CGI/man-cgi?find – Nux Nov 12 '14 at 13:53
  • @Nux: nice tip. `-printf '%9s %p\n'` worked well for me. – seanf May 29 '15 at 05:40
  • Building on this answer: `find /var/lib/docker/containers -name "*-json.log" -type f -size +100M -exec /bin/cp -f /dev/null {} \;` – Richard Feb 12 '20 at 20:09
  • @Nux The problem with using `%s` is that while the size it prints is machine parsable, it's not human-readable, whereas `ls -lh` shows a human readable size. – Asclepius Nov 19 '20 at 21:28
4

Use the following:

find / -size gt 2MB

or:

find / -size => 2000000 
  • 5
    How does this improve the accepted answer? – Dave M Feb 27 '17 at 13:18
  • 1
    Though we thank you for your answer, it would be better if it provided additional value on top of the other answers. In this case, your answer does not provide additional value, since another user already posted that solution. If a previous answer was helpful to you, you should vote it up instead of repeating the same information. – Toby Speight Feb 27 '17 at 13:42
  • Alternative syntax is sometimes useful and insightful. +1 – stupidstudent Dec 05 '22 at 11:13