
July 31st, 2012, 07:24 PM
|
|
|
The most obvious way of doing it is (not tested):
Code:
# We only want exactly one parameter
if [ $# -ne 1 ]
then
echo "Usage: $0 [larger|largest]"
exit 2
fi
# Only one parameter given, now check it is what we want
# Probably better to use tr to set it to lower (or upper) to
# be more user-friendly
case $1 in
larger)
du -a /example/dir | sort -n -r | head -n 20
;;
largest)
find /example/dir -size +1024
;;
*)
echo "Usage: $0 [larger|largest]"
exit 3
;;
esac
__________________
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc
|