<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
<font size="-1">I had this old script from work kicking around.  It
lists the largest n files in each directory in the specified path.  It
was originally written for Korn shell, but is ok for bash.<br>
<br>
lm -h will give a brief usage message.<br>
lm -5 /home will give the 5 largest files in each directory in /home,
etc.<br>
<br>
<br>
#!/bin/bash<br>
<br>
#d list largest [-n] files in each directory in path<br>
<br>
# defaults:<br>
<br>
#    -n     1<br>
#    -s     1 block ( 1024 bytes per block )<br>
#    [path] . ( current directory )<br>
<br>
USAGE="usage: lm [ -n n ] [ -s n ] [path]"<br>
<br>
# default parameters<br>
<br>
nh=1;                   # number of files<br>
MAX=`expr 1 \* 1024`            # max size of file<br>
spath=".";              # specified path<br>
<br>
# command-line parameters<br>
<br>
while getopts hn:s: c<br>
do<br>
case $c in<br>
    h)  usage $0 $USAGE;            # display help text<br>
    exit ;;<br>
    n)  nh=$OPTARG;;<br>
    s)  MAX=`expr $OPTARG \* 1024`;;<br>
    ?)  usage $0 $USAGE;<br>
    exit 1;;<br>
esac<br>
done<br>
<br>
shift `expr $OPTIND - 1`;       # search path<br>
<br>
if [ $# -eq 1 ]<br>
then<br>
    spath=$1;<br>
fi<br>
<br>
(<br>
<br>
 # for i in ( all dirs )<br>
<br>
 for i in `ls -FR $spath 2> /dev/null | sed -n 's/:$//p'`<br>
 do<br>
<br>
     c=`ls -l $i | sort -r -n +4 -5 | head -1 | awk '{ print $5; }'`;<br>
     if [ "$c" -gt $MAX ]<br>
     then<br>
<br>
     for j in `ls -l $i | awk -v max=$MAX '$5>=max { print $NF; }'`<br>
     do<br>
         ls -l $i/$j;<br>
     done<br>
<br>
     fi<br>
<br>
 done<br>
<br>
 ) 2> /dev/null | pg;<br>
<br>
I hope this helps.<br>
<br>
<br>
Neil Brown        <a class="moz-txt-link-abbreviated" href="mailto:brownn0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org">brownn0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org</a><br>
<br>
Toronto, Ontario, Canada<br>
<br>
</font>
</body>
</html>