#! /bin/sh

# $Copyright:	$
# Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
# Sequent Computer Systems, Inc.   All rights reserved.
#  
# This software is furnished under a license and may be used
# only in accordance with the terms of that license and with the
# inclusion of the above copyright notice.   This software may not
# be provided or otherwise made available to, or used by, any
# other person.  No title to or ownership of the software is
# hereby transferred.

#ident	"$Header: largest 1.4 89/10/11 $@(#)sadmin:shell/largest	1.3"
#	Find largest files under the given directory.

#!	chmod +x ${file}
if [ x$1 = x ]
then
	d=.
else
	d=$1
fi
if [ x$2 = x ]
then
	b=10
else
	b=$2
fi
echo "	the ${b} largest files under ${d}"
a="`expr 0${b} "*" 10`"
cd ${d}
du -a  |
  sort -bnr +0 -1  |
  sed -n 1,0${a}'s:^[0-9]*	\./:ls -ldsu :p'  |
  sh -  |
  grep -v '^ *[0-9][0-9]* d'  |
  sed -n 1,0${b}p  |
  sort -bnr +5 -6
