Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-23-2011, 08:34 AM   #1
Registered: Jun 2010
Posts: 147

Rep: Reputation: 9
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.

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
say for example
           |             | 
           ->dir2        |-file1
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)
Old 01-23-2011, 09:51 AM   #2
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 488

Rep: Reputation: 78
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...

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

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

1 members found this post helpful.
Old 01-23-2011, 10:05 AM   #3
Senior Member
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
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:

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

Last edited by Snark1994; 01-23-2011 at 10:06 AM.
Old 01-28-2011, 01:58 PM   #4
Registered: Jun 2010
Posts: 147

Original Poster
Rep: Reputation: 9
Hi thanks for the messages.You people guessed the correct things.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Howto Display Size of Files Under Files in Ubuntu LXer Syndicated Linux News 0 04-20-2010 03:50 PM
Unix rm files of same size Gurr Linux - Newbie 3 12-08-2006 05:22 AM
To search for files of a particular size mufy Linux - General 1 12-09-2004 01:44 AM
increase point size size when printing PDF files newlin Red Hat 0 09-27-2003 08:13 AM
delete files by size Serena Linux - Newbie 2 04-25-2002 08:38 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:57 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration