![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| largest field , awk , help | jkl_jkl | Shell Programming and Scripting | 6 | 3 Days Ago 03:21 PM |
| Expression for Finding Multiple Directories..?? | meskue | Shell Programming and Scripting | 3 | 07-10-2006 12:04 PM |
| Finding executable files in all directories | CSGUY | UNIX for Dummies Questions & Answers | 4 | 04-19-2005 03:34 PM |
| Finding largest file in current directory? | AusTex | High Level Programming | 1 | 03-13-2005 10:03 AM |
| finding directories in UNIX | yodaddy | UNIX for Dummies Questions & Answers | 1 | 11-08-2001 10:26 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
finding largest directories in a filesystem
I'm trying to come up with a way of finding largest directories in a filesystem (let's say filesystems is running ot of space and I need to find what is consuming all the space). If a directory is a single filesystem, then it's easy, I just run "du -sk *| sort -nr". But the problem is, if some subdirectories are on separate filesystems, then it will show those as well. It's especially hard to get filesystem usage on / since I have many filesystems on some boxes. I tried "du -skx *" but it still shows directories in child filesystems. Then I tried to do it with find command:
Code:
find . -xdev -type d -exec du -sk {} \; | sort -nr | head -10
|
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
man du (-x)
|
|
#3
|
|||
|
|||
|
Replace "*" with the name of the largest filesystem.
Code:
du -kx /fs |
|
#4
|
|||
|
|||
|
Hi,
You can check the largest files under directories and subdirectories by using the following command. ls -lR | sort +4 -5nr | head -10 R -- will check the files under subdirectories Thanks, Aketi |
|
#5
|
|||
|
|||
|
Quote:
Code:
:/]# du -kx / |sort -nr|head -10 5312843 / 4527973 /usr 1951796 /usr/lib 1735880 /usr/share 952800 /usr/lib/ooo-1.1 743964 /usr/lib/ooo-1.1/program 613476 /usr/lib/ooo-1.1/program/resource 381064 /usr/share/doc 310004 /opt 284383 /var Code:
:/]# for DIR in `ls -1`; do mount | grep /"$DIR" | grep -v /"$DIR"/ > /dev/null || du -skx $DIR; done |sort -nr|head 4527973 usr 310004 opt 284383 var 85468 lib 62344 etc 19056 RedHat 15580 sbin 1668 tmp 468 media 200 dev |
|
#6
|
|||
|
|||
|
The ls in backticks is not really Useful. I guess you can also cut out the second grep by anchoring the end of the search string.
Code:
for DIR in *; do mount | grep /"$DIR$" > /dev/null || du -skx "$DIR"; done |sort -nr|head |
|
#7
|
|||
|
|||
|
Quote:
The grep situation is a bit tricky. I'm really looking for a string in the "mount" output that does "not" have / at the end. For example, if I'm at / and have a filesystem mounted at /ks-images/rhel4, I still want to include /ks-images in my output. So came up with a stupid trick of first looking for "/ks-images" and then looking for anything that doesn't match "/ks-images/". "$" doesn't help, in fact the mount point is not even at the end of the line. I'm sure there's a better way, I could use help with this... |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|