LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   using du to see files of a particular size only (https://www.linuxquestions.org/questions/linux-newbie-8/using-du-to-see-files-of-a-particular-size-only-858123/)

jamesbon 01-23-2011 07:34 AM

using du to see files of a particular size only
 
I am having a few situations to which I do not see any thing in du man pages.

Quote:

1) I want to see files in a sub directory which are larger than a particular size only.
2) I use du -sh > du_output.txt I see the output as described for option -s and -h
how ever what I am more interested is if the output comes in a format which
is
say for example
Code:

    dir0--->dir1-->dir3-->dir4
          |            |
          ->dir2        |-file1
                        |-file2

if the above is directory layout and I want to just see the size of individual directories in all the subdirectories then what can I do (the depth of each subdirectory is variable)

rayfordj 01-23-2011 08:51 AM

I don't know that I completely understand what you are looking for and/or asking so if I am way off please expand on your example/request...

Code:

find ./sub-directory/ -type f -size +300M -print
find ./sub-directory/ -type f -size +300M -exec du -sh {} \;

where 'f' is for file and '+300M' is of size 300M or greater
the 2nd line is if you want the output to be that of du


Code:

find ./sub-directory/ -type d -exec du -sh {} \;
find ./sub-directory/ -maxdepth 3 -type d -exec du -sh {} \;

where 'd' is for directory and the 2nd line just says don't descent more than '3' deep


:study:

Snark1994 01-23-2011 09:05 AM

If I understand you correctly ("I want to see files in a sub directory which are larger than a particular size only"), you can use:

Code:

find . -printf "%h/%f %s\n" | awk '{if ($2 > 200) print $1, $2}'
...replacing 200 with the minimum filesize in bytes. However, you seemed to be talking about several different things, so if this isn't what you wanted, then perhaps you just need to clarify :)

EDIT: Beaten to it by rayfordj. He seems to have gone with a similar interpretation to the one I assumed... As before, tell us if we're misunderstanding you

jamesbon 01-28-2011 12:58 PM

Hi thanks for the messages.You people guessed the correct things.


All times are GMT -5. The time now is 05:30 AM.