This article will go through some basic examples on how to list files above or below a certain size in Linux using the find command. There are many use cases for running queries like this, for instance finding small files on your hard drive or finding very large files. So, lets get started with some examples.
Using find to show files below a certain size (1000 bytes = 1K)
find . -type f -size -1000 -ls
Using find to show files above a certain size (1,000,000 bytes = 1M)
find . -type f -size +1000000 -ls
In the above commands, the -ls command will display the file size, date, and other attributes regarding the file. If you would like just the path and filename, then omit the -ls.
Thanks for the tip.
for the record, on ubuntu 12.04, I had to use this:
find . -type f -size -1000c -ls
the small ‘c’ is required to work with bytes, otherwise it uses 512-byte blocks (e.g. option ‘b’ instead of ‘c’). Counter-intuitive, I know …
Alex,
Thanks for leaving your feedback on the article and suggested a change for Ubuntu!
heat