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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
10-23-2005, 09:26 PM
|
#1
|
LQ Newbie
Registered: Sep 2005
Posts: 6
Rep:
|
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
|
|
|
10-23-2005, 11:52 PM
|
#2
|
Member
Registered: Jan 2005
Posts: 83
Rep:
|
du -kh | sort -nr | less
|
|
|
10-24-2005, 12:22 AM
|
#3
|
LQ Veteran
Registered: Mar 2003
Location: Boise, ID
Distribution: Mint
Posts: 6,642
Rep:
|
du -h --max-depth=1
|
|
|
10-24-2005, 01:33 AM
|
#4
|
Member
Registered: Jul 2003
Location: Osaka, Japan
Distribution: Arch, Ubuntu
Posts: 421
Rep:
|
1. cd into the dir.
2. du -sh *
This doesn't show hidden files, so
du -sh .*
to show them. Notice the dot(.)?
|
|
|
10-24-2005, 03:05 AM
|
#5
|
LQ Newbie
Registered: Sep 2005
Posts: 6
Original Poster
Rep:
|
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 =)
|
|
|
10-24-2005, 04:07 AM
|
#6
|
ROCK Linux
Registered: Dec 2003
Location: Berlin, Germany
Distribution: Crystal ROCK
Posts: 108
Rep:
|
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
|
|
|
10-24-2005, 04:56 AM
|
#7
|
LQ Newbie
Registered: Sep 2005
Posts: 6
Original Poster
Rep:
|
Thx Benji =)
Yipe, just wat I needed!
|
|
|
All times are GMT -5. The time now is 01:09 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|