Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
How do I find out what the largest files are in a file system?? In other words, if I get the message that /tmp is 90% full and /tmp is not a raw slice but a file system, how do I find out what the 20 largest files are and their complete path??
Any help on this would be very much appreciated...
Thanks!!
Bill

Other people will probably be able to write some nice scripts for you, but I've found the best solution on Linux to be fsv. I don't know much about HP-UX, but I found what looks to be an HP-UX version of fsv.

Bill:
Here's a one liner getting the 20 largest files in /tmp:
# all on one line
find /tmp -type f -print | xargs ls -l | sort -r -n -k 5,5 | head -20Regards,
Nails

You could also do the ls within the find command like this:
find /tmp -type f -exec ls -la {} \; | sort -r -n -k 5,5 | head -20

Hi:
Most modern *nixes probably avoid the problem, but using find's -exec is always a risk of overflowing the command-line buffer given enough files. Using xargs guarantees this won't happen.
Regards,
Nails

Nails,
I tried your xargs command and that got me most of what I wanted...The problem is that I got the 20 largest files under /tmp, but I didn't get the 20 largest files in the /tmp "filesystem"...
When I ran it on the 2 largest files I got this:
-rw-r--r-- 1 oracle dba 714559 Aug 20 2002 /tmp/admin/export.dmp
-rw-r----- 1 oracle dba 558828 May 16 2002 /tmp/files/dh_out.txtIf I go and do a "df -k ." from /tmp/admin and /tmp/files, I get two different filesystems (see below):
/tmp/admin (/dev/vg00/lvol1) : 8733 total allocated Kb
1893621 free allocated Kb
6840322 used allocated Kb
78 % allocation used/tmp/files (/dev/vg01/lvol1) : 4059 total allocated Kb
2145 free allocated Kb
3787 used allocated Kb
47 % allocation usedDo you have any ideas or suggestions??
Thanks for your help so far!!
Bill

Bill:
It should work. You must have links in your /tmp file system. I don't know about HP-UX, but the Solaris find has a -follow option which means "to follow the link". This might help:
find /tmp -type f -follow -print | xargs ls -l | sort -r -n -k 5,5 | head -20
Regards,
Nails

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |