How do I find out all large files in a directory?
1. For RedHat / CentOS / Fedorafind {/path/to/directory/} -type f -size +{size-in-kb}k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
2. For Debian / Ubuntu Linuxfind {/path/to/directory} -type f -size +{file-size-in-kb}k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'
How to find out top 10 largest file/directories?du -a /path/to/dir/ | sort -n -r | head -n 10
where
du is to Estimate file space usage.
sort is to sort lines of text files or given input data.
head is to output the first part of files i.e. to display first 10 largest file.
find is to Search file
How to find the largest file in a directory and its subdirectories using the find command?
find /path/to/dir/ -printf '%s %p\n'| sort -nr | head -10
You can skip directories and only display files, type:find /path/to/dir/ -type f -printf '%s %p\n'| sort -nr | head -10
How to find all files of a particular size?find /home/ -type f -size 100M -exec ls {} \;
b – for 512-byte blocks (this is the default if no suffix is used)
c – for bytes
w – for two-byte words
k – for Kilobytes (units of 1024 bytes)
M – for Megabytes (units of 1048576 bytes)
G – for Gigabytes (units of 1073741824 bytes)