Some times it is required to find big files which are eating out Harddisk space. We have to find them and delete them if they are not worth to keep. This can be done by using find command with -size option.

find files of size more than 123MB in /Telecom folder

find /Telecom/ -type f -size +123000k -exec ls -lh {} ;
The above command will find all the files(-type f) in /Telecom folder which are more than 123.0MB(-size 123000k) 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
-rw-r–r– 1 lsablimsta root 224M Oct 11 17:49 /Telecom/lsablimsta/511/
-rw-r–r– 1 lsablimsta root 154M Jan 21 16:22 /Telecom/lsablimsta/Veena/
With more meaningful 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 from entire machine.

find / -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 meaningful 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 delete the files without 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.

Try to explore your self with find command and enjoy 🙂

The following two tabs change content below.
Mr Surendra Anne is from Vijayawada, Andhra Pradesh, India. He is a Linux/Open source supporter who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. He works as Devops Engineer with Taggle systems, an IOT automatic water metering company, Sydney . You can contact him at surendra (@) linuxnix dot com.