
There is no direct command in finding large files in Linux. We have to use find command and other tools to find large files which are eating up our disks.
#find /Telecom/ -type f -size +123234k -exec ls -lh {} \;
The above command will find all the files(-type f) in /Telecom folder which are more than 123.234MB(-size 123324k) and lists them in a human readable format. So if you want to find files which are in GB just give that value after -size as shown.
Sample output :
-rw-r--r-- 1 lsablimsta root 188M Oct 11 15:43 /Telecom/SP8 Db Export.zip -rw-r--r-- 1 lsablimsta root 224M Oct 11 17:49 /Telecom/lsablimsta/511/server.zip -rw-r--r-- 1 lsablimsta root 154M Jan 21 16:22 /Telecom/lsablimsta/Veena/tools.zip
With more meaning full way, if you want to search all big files which are not accessed from long time say suppose from last 6 months. You can use below command.
#find /Telecom -type f -atime +180 -size +123456k -exec ls -lh {} \;
Sample output :
-rw-r--r-- 1 seven root 2.6G Jun 24 2010 /Telecom/seven/amit/connector.log-2010-06-23 -rwxrwx--- 1 seven seven 1010M Jan 7 2008 /Telecom/seven/Logs_1228/2007_12_28_dshost.log -rwxrwx--- 1 seven seven 154M Jan 23 2008 /Telecom/seven/2008_01_23_sentry.log
Here I have just added -atime to mention last access time as 6 months(180 days)
With some more meaning full way. To give only file sizes and file paths use below command.
#find /Telecom -type f -atime +180 -size 1233456k -exec ls -lh {} \; \
| awk '{print $5,$9}'
Sample output :
2.6G /Telecom/seven/amit/connector.log-2010-06-23 1010M /Telecom/seven/Logs_1228/2007_12_28_dshost.log 154M /Telecom/seven/SEGDisconnect/22'nd 213M /Telecom/seven/SEGDisconnect/SEG 444M /Telecom/seven/SEGDisconnect/SEG
If you want to right away delete the files with out seeing output you can replace ls -lh with rm -rf as shown below.
#find /Telecom -type f -atime +180 -size 1233456k -exec rm -rf {} \;
Sample output :
No sample output as it will delete all the file which met the above criteria.
Ok. now no more meaning full ways. Try to explore your self with find command and enjoy







