• RSS
  • SmsJobs
  • Sms
  • GoogleBuzz
  • Facebook
  • Twitter
  • Linkedin
  • Youtube
The Linux Juggernaut

The Linux Juggernaut

roles on……

Do you like www.linuxnix.com ? Please consider supporting us by becoming a subscriber and get a Linux basics e-book for free.
linux-find-command

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 :)

Do you like www.linuxnix.com ? Please consider supporting us by becoming a subscriber and get a Linux basics e-book for free.
bySurendra Anne On Friday-February - 18 - 2011

email newsletter

Redhat Flagship dist

Redhat announced that they are going to release RHEL7 by ...

12 examples to use f

Flower brackets examples This is a small post on how to ...

7 Linux read command

read command examples read command is useful in scripts when reading ...

7 linux sort command

Linux/Unix sort command examples This is a small tutorial on how ...

How to find command

How to find command location in Linux and Unix This is ...

  • About Linux Juggernaut

    How the blog name selected? Juggernaut: * a massive inexorable force that seems to crush everything in its way ...readmore>>

  • Contact Me

    Contact us Send an Email Phone number and vCard LinkedIn profile Advertise with us
  • About Me

    Surendra Kumar Chowdary

    My name is Surendra Kumar Anne. I am from Vijayawada which is cultural capital of south Indian state of Andhra Pradesh. I am a Linux evangelist who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. At present i work at Persistent Systems as Module Lead.   read more »