Thursday, August 14, 2014

How to find files which are more than a particular size in centos fedora redhat

There maybe the case when you need to find the files which are more than a particular size, Use the below command cum script to achieve the same. 

In the below command 1024M is the file size in MB, You can change the parameter value as per your search requirement.

============
root@testvps [~]# find / -xdev -type f -size +1024M -exec ls -lh {} \;
-rw-r--r-- 1 root root 1.2G Sep 16  2010 /root/dexter.tar.gz
-rw-r--r-- 1 root root 1.5G Jul 30 21:07 /root/files.tar.gz
-rw-r--r-- 1 root root 13.2G Jul 30 21:08 /root/mysqlzipfiles.zip
============

Further i have updated the command to only show the file name with its location and size using awk which shows only column 9 and column 5 in the output.

============
[root@server ~]# find / -xdev -type f -size +1024M -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
/root/centos-5.tar.gz: 3.6G
/home/centos-6.tar.gz: 1.3G
/root/ubuntu-10.04-x86.tar.gz: 1.2G
============

No comments:

Post a Comment

Do Write about the Blog and Welcome to the world where open source is every thing :-)