LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 10-23-2005, 10:26 PM   #1
tsilok
LQ Newbie
 
Registered: Sep 2005
Posts: 6

Rep: Reputation: 0
Question How to list file space usage estimate (du), SPECIFIED BY RANGE


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
 
Old 10-24-2005, 12:52 AM   #2
solveit
Member
 
Registered: Jan 2005
Posts: 83

Rep: Reputation: 15
du -kh | sort -nr | less
 
Old 10-24-2005, 01:22 AM   #3
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Boise, ID
Distribution: Mint
Posts: 6,642

Rep: Reputation: 83
du -h --max-depth=1
 
Old 10-24-2005, 02:33 AM   #4
koyi
Member
 
Registered: Jul 2003
Location: Osaka, Japan
Distribution: Arch, Ubuntu
Posts: 421

Rep: Reputation: 31
1. cd into the dir.
2. du -sh *

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

Original Poster
Rep: Reputation: 0
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 =)
 
Old 10-24-2005, 05:07 AM   #6
blindcoder
ROCK Linux
 
Registered: Dec 2003
Location: Berlin, Germany
Distribution: Crystal ROCK
Posts: 108

Rep: Reputation: 15
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
 
Old 10-24-2005, 05:56 AM   #7
tsilok
LQ Newbie
 
Registered: Sep 2005
Posts: 6

Original Poster
Rep: Reputation: 0
Thx Benji =)
Yipe, just wat I needed!
 
  


Reply


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
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 10:49 AM.

Main Menu
Advertisement
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
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration