This can be easily done using the find command. The general syntax is
find . -type f -size +<size> -exec ls -al {} \;
Here are the suffixes available for the size
b – 512-byte blocks (this is the default if no suffix is used)
c – bytes
w – two-byte words
k – Kilobytes
M – Megabytes
G – Gigabytes
If you dont want to list the size, then you can use the below command also
find . -type f -size +<size>
How to find files greater than 1 GB
find . -type f -size +1G -exec ls -al {} \;
This will search in your current directory and subdirectories
If you want to search in /, you can put a command like
find / -type f -size +1G -exec ls -al {} \;
If you want to do it in your home directory, then
find ~/ -type f -size +1G -exec ls -al {} \;
You can provide specific directories also
find /u02 -type f -size +1G -exec ls -al {} \;
How to find files greater than 100 M
find . -type f -size +100M -exec ls -al {} \;
How to find empty files
find / -size 0 -exec ls -al {} \;
How to find files smaller than 100M
find . -type f -size -100M -exec ls -al {} \;
how to find the file in a range of size in Linux
You can find this using the above operator explained above
find . -type f -size +100M -size -200M -exec ls -al {} \;
You can specify whatever size is required
I hope you like this content on how to find file based on size in linux. Please do provide the feedback
Related Articles
find command in Unix with example
Useful Unix/Linux command for Oracle DBA
Grep equivalent in Windows
grep examples
Leave a Reply