You are not logged in.
I have been using this perl script for years.
Found it on the internet.
Can not remember where though:
#!/usr/bin/perl
@queue = @ARGV;
while ($current = shift (@queue) ) {
opendir DH,$current;
@content = readdir DH;
foreach $item (@content) {
next if ($item =~ /^\.{1,2}$/);
$fullname = "$current/$item";
if (-l $fullname) { next; }
if (-d $fullname) {
push @queue,$fullname;
next;
}
if (-s $fullname > 100000) {
$big{$fullname} = -s $fullname;
}
}
}
foreach $item (sort {$big{$b}<=>$big{$a}} keys %big) {
printf ("%8d %s\n",$big{$item}, $item);
}
Save this script in a directory on your PATH (e.g. find-biggest-files.pl )and make it executable.
There is a hard limit in there of 100000. Smaller files are ignored.
To find the biggest files in your root dir:
find-biggest-files.pl /
PS:
1. it will search all mounted partions. If you dont want that, umount them first.
2. you can specify multiple directories to be searched as arguments on the command line.
hth
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
on my machine this runs much faster:
find -x some/dir/foo ! -type d -exec du -d 0 {} + | sort -n
or if you do not care to skip the directories:
du -xa some/dir/foo | sort -n
Note: the -x option will case both find and du to stay on the partition so you do not have to unmount something first..
Offline
Very cool.
Try ncdu too, it's in the repositories.
Offline
@luc: What du implementation is this? I'm @work, sitting in front of a recent Ubuntu box, seing no -d switch in the manpage. Doh!
I'm so meta, even this acronym
Offline
@awebb: thats bsd du. you have to use "--max-depth=0" or "--summarize". Sorry didn't think about that
Offline
^me neither on Squeeze. Could '-d 0' be an alias for '--max-depth?=0' ?
edit oops, sorry Luc, you got in with the answer while I was posting that.
Last edited by johnraff (2011-10-08 04:53:22)
John
--------------------
( a boring Japan blog , Japan Links, idle twitterings and GitStuff )
#! forum moderator BunsenLabs
Offline
OK,
replaced perl script by
du -xa some/dir/foo | sort -n
thanks luc
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
I apologize for the confusion about the -d option. I just retested my code and I think it is not needed at all, as directories are not picked up by find due to "! -type d". But you where right john. It is the BSD version of the GNU option "--max-depth".
The new code is now:
find -x some/dir/foo ! -type d -exec du {} + | sort -n
Offline
On debian:
find some/dir/foo -xdev ! -type d -exec du {} + | sort -n
so I propose:
find some/dir/foo -xdev ! -type d -exec du {} + | sort -nr | head
for top 10 biggest files.
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
Maybe add du's -h option for human-readable sizes?
find some/dir/foo -xdev ! -type d -exec du -h {} + | sort -nr | head
John
--------------------
( a boring Japan blog , Japan Links, idle twitterings and GitStuff )
#! forum moderator BunsenLabs
Offline
but can "sort" sort that in the right way? I get
...
9K file0
10M file1
10K file2
...
if I use "sort -n"
Offline
^good point. I can't think of any way round that.
John
--------------------
( a boring Japan blog , Japan Links, idle twitterings and GitStuff )
#! forum moderator BunsenLabs
Offline
AWK! That's not only the sound the creature on your userpic makes ;-)
I'm so meta, even this acronym
Offline
^...true... any suggestions as to how to get 2M to display above 10k with awk?
...or maybe better to sort first, then convert 20000 to 20K etc?
John
--------------------
( a boring Japan blog , Japan Links, idle twitterings and GitStuff )
#! forum moderator BunsenLabs
Offline
Yes. Sort first, then convert the numbers. I must admit I'd write an ugly chain of sed+regex, because my AWK-fu is still in the sign of a very low Kyū...
I'm so meta, even this acronym
Offline
but can "sort" sort that in the right way? I get
... 9K file0 10M file1 10K file2 ...
if I use "sort -n"
This can be achieved with
$ sort -h
-h, --human-numeric-sort
compare human readable numbers (e.g., 2K 1G)
Offline
Haha, sometimes a man page is a man page is a man page.
I'm so meta, even this acronym
Offline
This can be achieved with
$ sort -h
WOW
John
--------------------
( a boring Japan blog , Japan Links, idle twitterings and GitStuff )
#! forum moderator BunsenLabs
Offline
blame on me sorry guys for making a fuss after not rtfm.
Offline
^we're all equally guilty.
John
--------------------
( a boring Japan blog , Japan Links, idle twitterings and GitStuff )
#! forum moderator BunsenLabs
Offline
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat