- How to find files larger than 10MB, 100MB, 1GB in Linux
- Searching the larger files in Linux
- Find files by size and extension
- Linux Command , how to find files by size larger than x?
- 4 Answers 4
- How to find all files with size greater than.
- 4 Answers 4
- Find files greater than x kB/MB/GB in size, and also show their size
- See also:
- 3 Answers 3
How to find files larger than 10MB, 100MB, 1GB in Linux
If you’re looking for files that are larger than 10MB, 100MB or 1GB, the find command can be very helpful. With find, you can search for files based on size criteria.
A few days back my production application goes down. After searching for half an hour, I found the application was down due to the disk full on my server. So I searched all files greater than 1 GB and then all files greater than 100 MB. There were a few log files that were large in size, which caused the disk full.
In this tutorial, you will learn how to search file by their size using find command.
Searching the larger files in Linux
You can define size in KB, MB and GB formats. For example, you can define size 100K, 100M, 1G or 10G formats. Use below examples, which will help you to find files by there size and extension.
- The following command will find all file greater than equals to 100MB under entire file system.
This would search through the entire file system and return a list of all files that are larger than 100MB. If you only want to search a specific directory, you can replace “/” with the path to that directory. For example, if you only wanted to search your home directory, you could use this command:
Find files by size and extension
Instead of searching all files, you can also search files of specific extensions greater than 1G B size. For example search, all files with extension “.log” and size are 1GB or more.
find / -type f -name "*.log" -size +1G
Related Topics
Linux Command , how to find files by size larger than x?
I’m trying to find files with size larger than «x» , ex: 32 bytes But what I found in ls —help was only ls -S , that just sort by size and not satisfied my demand I’m new to Linux , I’ve tried Google but I don’t know what keywords should I use to find answer , could somebody give me advice , thank you !
Your question is not about programing but about linux command that would be better in serverfault.com. If you want to ask something about shell script please read this first. stackoverflow.com/help/mcve
4 Answers 4
Try to use the power of find utility.
Find files greater than 32 bytes:
Of course you could also ask for files smaller than 32 bytes:
And files with exact 32 bytes:
For files with 32 bytes or more:
Or not smaller than 32 bytes (the same as above, but written another way):
And files between 32 and 64 bytes:
And you can also apply other common suffixes:
If you get find: illegal option — i error, specify the folder to search in after find . Add a dot to find files in the current folder: find . -size +32k -size -64M
You can change 32 for the size you want. In this case, I used your example.
Both answers you two provided me are excellent 😀 But I think I will give @rslemos the best answer tag since he’s «1 minute earier» , but still thanks to you !
Explanation: Use unix command find Using -size oprator
The find utility recursively descends the directory tree for each path listed, evaluating an expression (composed of the ‘primaries’ and ‘operands’) in terms of each file in the tree.
Solution: According to the documentation
-size n[ckMGTP] True if the file's size, rounded up, in 512-byte blocks is n. If n is fol- lowed by a c, than the primary is true if the file's size is n bytes (charac- ters). Similarly if n is followed by a scale indicator than the file's size is compared to n scaled as: k kilobytes (1024 bytes) M megabytes (1024 kilobytes) G gigabytes (1024 megabytes) T terabytes (1024 gigabytes) P petabytes (1024 terabytes)
Usage: perform find operation with -size flag and threshold measurement arguments: more than(+)/less than(-), number(n) and measurement type (k/M/G/T/P).
Formula: find -size [+/-]
1.Greater Than — Find all files in my current directory (.) that greater than 500 kilobyte
2.Less Than — Find all files in my current directory (.) that less than 100 megabyte.
3.Range — Find specific file (test) in my current directory (.) that greater than 500 kilobyte less than 100 megabyte (500k-1000k)
find . -name "test" -size +500k -size -100M
4.Complex Range with Regex Find all .mkv files in all filesystem (root /) that are greater than 1 gigabyte and created this month, and present info of them.
find / -name "*.mkv" -size +1G -type f -ctime -4w | xargs ls -la
How to find all files with size greater than.
Is there any GUI software that can explore a tree and find all files with size greater than some amount? Neither Nautilus nor Nemo seem to be able to do this. In my memory, I could do this with PC-Tools in DOS 3.0.
4 Answers 4
sudo apt-get install baobab baobad
There is a bunch more on this question of SuperUser, but for all ends and propose baobad is enough.
Thank you Braiam, but baobab can’t be useful as it won’t have file search/sort option. More, since Unity the menu is broken (no more edit/preferences to exclude files/folder) and I get an error analysing my own «/home/me or some of its subfolders», maybe authorizations of .ssh, and no message to direct me to a log. so. find may work better, but it is not a gui, and everytime (which is not often) it could be useful, in the urgency, I forgot the syntax, so. find is not for my humanity.
@useful there are a bunch more on the SU link, I won’t bother to bring them since. mm. it will give the impression that you want a list and you want not (nor is encouraged in SE), either way, give the link a shot, if you feel that some of them solves your problem. BTW, as you can notice I prefer CLI solutions over GUI’s since. mmm. I’m like that ;).
When I need make more free space on servers I use this command. It find all files bigger then 50 MB and «du -h» make berret list of files and «sort -n» after pipe make list numericcaly sorted by file size.
find / -type f -size +50M -exec du -h <> \; | sort -n
Oh what a nice a handy GUI. It is just too easy for a newb like me, but waiting for the same in assembly language. waiting for the machine code which is the top in elegance, I’ll stick to gnome-search-tool. -1
I know you search GUI tool, but if you will learn more with Bash then you know this in all distros and environments. For easier understanding I explain this for you. If you need I can explain this in more details, it is really easy and very useful.
Thank you zorbon.cz. Sorry for my ironic way, but I have so much other issue with command line tool that should work just as intended but doesn’t, so then I easy get irascible when some answer comes that obviously doesn’t take care of the care I asked with. Well the point is that I’m not that newb, intermediate computers user instead, so I often run in frustration with Linux. yes I know it’s the price of freedom and there is still Windows if I want to switch back. but I put the finger in the shredder. Anyway I recognize your gentle pre-comment on your command line: I didn’t see it at first
My main frustration is how could I dare advise anyone to use this OS when I can’t even help myself so often.
Sorry, maybe one of my reason to answer that is fact that I now use Windows 8.1 🙂 since Windows 8 RTM (more than 2 years) and I can not switch back to linux (and I’d like do it), because there are not alternatives to some tools) and now I donť know «nothing» about GUI. But I see CLI every day as sysadmin (I manages higher tens of servers running on CentOS or some on Debian). I understand your last mention and it is true fact.
gnome-search-tool is what I use. Very simple. It has the «Size is at least» filter where you can specify minimum file size. See screen print for searching my ISOs folder with a minimum size of 10,000,000 KB in size.
Thank you rik.shaw, I completly forgot this since I use unity, and as I thought gnome-search-tool was a feature/companion of Nautilus (what I now know is false) growing . more and more spartan, so I switched to Nemo (which, btw, doesn’t help more in that matter of searching), so I was stuck. I will give a try back to it although I remember issues in gnome-search-tool keeping searching for hours when it met unauthorized directories or files or looping through links. Anyway, even if there isn’t a better tool, at least it was the kind of answer I expected. Thank you again.
Find files greater than x kB/MB/GB in size, and also show their size
I’d like a simple command (perhaps using find ) which finds all files > some size in bytes, kilobytes, megabytes, or gigabytes, and which prints their size as they are found. This command, for instance, finds all files > 10 MB, but does not show their size, unfortunately:
See also:
- Files greater than 1 GB and older than 6 months — doesn’t show size
- Linux show files in directory larger than 1 GB and show size — accepted answer looks more-complicated than expected, and I don’t need sorting.
- Find files greater than X value, sort by size, show in ls format — I don’t need nor want ls format, and main answer may not work with spaces
- https://linuxconfig.org/how-to-use-find-command-to-search-for-files-based-on-file-size
3 Answers 3
Note that the M in find . -size +10M , is a GNU extension. The GNU implementation of find has another extension: -printf that you can use to print the size of those files:
find . -size +10M -printf '%s %p\n'
To report the s ize and p ath of the files that are more than 10MiB (mebibytes, not megabytes¹) large.
Here, you could also use zsh and its stat builtin and glob qualifiers:
zmodload zsh/stat stat -nL +size -- **/*(LM+10)
That prints the size after the file path. Also note that contrary to find , that excludes hidden files by default (you can add them back with the D qualifier).
Or to print r aw on 2 C olumns ( a cross):
stat -nLA report +size -- **/*(LM+10) print -raC2 -- $report
Note that all those -size , %s , +size consider the file’s size, which is not the same as the file’s disk usage² as reported by du (or %b / %k in gfind -printf , or +block in zsh ‘s stat, though du also includes the size of unique files within for files of type directory). find has no predicate to filter files based on their disk usage.
¹ for files larger than 10 MB (megabyte), you’d need -size +10000000c (standard) in find or (L+10000000) in zsh
² bigger files generally take up more disk space, but not necessarily and in any case the relation between the the two is not linear.