fredforfaen

My trip through Linuxland

Search a drive for large files in Linux

Note:
How can i find large files on my Linux box ?
Well crack open your terminal and try this:

find / -type f -size +200M

This finds all files larger than 200 mb. Of-course you can turn that around and look for files smaller than 200 mb ….if so, just do this:

find / -type f -size -200M

The / can be anything of your choice … for example if i want to search my home dir for files i would do this:

find /home/thomas -type f -size +200M

This would find all files larger than 200 mb in /home/thomas.

Now you would maybe want to search or save the output of this command. To search it you could just use grep, like this :

find /home/thomas -type f -size +200M|grep avi

All files larger than 200 mb containing the keyword avi will be shown. Now you may want to save your output in a file, do this

find /home/thomas -type f -size +200M > largefilelist

This finds all files larger than 200 mb in /home/thomas and saves it as a text file called largefilelist. Well now you may want to search that file, do this:

cat /your/path/to/largefilelist|grep avi

This finds all files containing the keyword avi in the file largefilelist. If you have several output files you want to combine, do this:

cat file1 file2 file3 > joinedfiles

This combines file1, 2 and 3 in one merged file called joinedfiles.

Hope this is usefull in some way.Thats all for now :)

June 10, 2007 - Posted by fredforfaen | Hints and tips | | 2 Comments

2 Comments »

  1. Found this page through a quick Google search and it helped a lot.

    One thing that I found different for my version of find was that the ‘M’ in +200M was not accepted. If I remove this and instead of +200 I use +200000000 (200MB in B) then it works fine.

    Thanks!

    Comment by Ryan | October 31, 2007 | Reply

  2. find / -size +10M -exec -ls -sh {} \;

    shows the file size also.

    Comment by Johan de Jong | March 22, 2008 | Reply


Leave a comment