LinuxQuestions.org
Social Bookmarking all things Linux and Open Source
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Newbie
User Name
Password
Linux - Newbie This 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!

Notices

Reply
 
Thread Tools
Old 10-23-2005, 10:26 PM   #1
tsilok
LQ Newbie
 
Registered: Sep 2005
Posts: 6
Thanked: 0
Question How to list file space usage estimate (du), SPECIFIED BY RANGE


[Log in to get rid of this advertisement]
Morning,

My server disk storage is running out. I know I can see all sub dir disk usage using du -h. But the outcome of this command is too lengthy because there are a lot of subdir under my parent dir.

I just want to specifically list all subdir under a dir, with dir size greater than 5M, maybe. Is this possible?

Thx,
Tsi Lok
tsilok is offline     Reply With Quote
Old 10-24-2005, 12:52 AM   #2
solveit
Member
 
Registered: Jan 2005
Posts: 83
Thanked: 0
du -kh | sort -nr | less
solveit is offline     Reply With Quote
Old 10-24-2005, 01:22 AM   #3
J.W.
Moderator
 
Registered: Mar 2003
Location: Milwaukee, WI
Distribution: Slack v12, SuSE v11.1, Mint v7
Posts: 6,620
Thanked: 5
du -h --max-depth=1
J.W. is offline     Reply With Quote
Old 10-24-2005, 02:33 AM   #4
koyi
Member
 
Registered: Jul 2003
Location: Osaka, Japan
Distribution: Arch, Ubuntu, MacOS X(Panther), winXP
Posts: 417
Thanked: 0
1. cd into the dir.
2. du -sh *

This doesn't show hidden files, so
du -sh .*
to show them. Notice the dot(.)?
koyi is offline     Reply With Quote
Old 10-24-2005, 04:05 AM   #5
tsilok
LQ Newbie
 
Registered: Sep 2005
Posts: 6
Thanked: 0

Original Poster
Dear all,

Thx for the solutions but all are still unable to allow me to filter the outcome by size. Anyway, your solutions have eased my work.

Thx a bunch =)
tsilok is offline     Reply With Quote
Old 10-24-2005, 05:07 AM   #6
blindcoder
ROCK Linux
 
Registered: Dec 2003
Location: Berlin, Germany
Distribution: Crystal ROCK
Posts: 108
Thanked: 0
Re: How to list file space usage estimate (du), SPECIFIED BY RANGE

Quote:
Originally posted by tsilok

I just want to specifically list all subdir under a dir, with dir size greater than 5M, maybe. Is this possible?
This should do the trick:
Code:
#!/bin/bash
min=$(( 1024*1024*5 )) # this is 5 MB
du -sb "$@" | while read size path ; do
        [ ${size} -gt ${min} ] && echo -e "${size}\t${path}"
done
Put this into a file called - for example - sizeme.sh, make it executable with chmod +x sizeme.sh and call it like this:
Code:
sizeme.sh /home/foo/*
HTH,
Benjamin
blindcoder is offline     Reply With Quote
Old 10-24-2005, 05:56 AM   #7
tsilok
LQ Newbie
 
Registered: Sep 2005
Posts: 6
Thanked: 0

Original Poster
Thx Benji =)
Yipe, just wat I needed!
tsilok is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
How do I determine disk space usage? econnections Linux - Newbie 4 08-28-2005 06:16 PM
Disk Space Usage Question kaplan71 Linux - General 6 04-11-2005 03:22 PM
How to List files between date1 and date2 (range of time)? mystique98ls Linux - Newbie 2 09-10-2004 05:36 PM
usage of disk space in a folder... Claus Linux - Software 4 09-10-2003 11:45 AM


All times are GMT -5. The time now is 11:21 AM.

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