Sunday, 17 June 2012

Write a shell script to find the file or directory with the maximum size in the current directory


max=0
for i in `ls -l|tr -s " "|cut -f 5 -d " "`
do
if [ $max -le $i ]
then
max=$i
fi
done
echo maximum size is: $max

No comments:

Post a Comment