LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to list file space usage estimate (du), SPECIFIED BY RANGE (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-list-file-space-usage-estimate-du-specified-by-range-376202/)

tsilok 10-23-2005 09:26 PM

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

solveit 10-23-2005 11:52 PM

du -kh | sort -nr | less

J.W. 10-24-2005 12:22 AM

du -h --max-depth=1

koyi 10-24-2005 01:33 AM

1. cd into the dir.
2. du -sh *

This doesn't show hidden files, so
du -sh .*
to show them. Notice the dot(.)?

tsilok 10-24-2005 03:05 AM

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 =)

blindcoder 10-24-2005 04:07 AM

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

tsilok 10-24-2005 04:56 AM

Thx Benji =)
Yipe, just wat I needed!


All times are GMT -5. The time now is 03:18 AM.