Monday 20 July 2020

Shell script to count the number of files whose size exceeds 100 bytes.


Program


c=0
for i in *
do
     if test -f $i
     then
        s=`ls -l $i | tr -s " " | cut -d " " -f5`
        if test $s -gt 100
        then
           c=`expr $c + 1`
        fi
     fi
done
echo "Number of files whose size exceeds 100 bytes is:$c"




OUTPUT
Number of files whose size exceeds 100 bytes is:91

No comments:

Post a Comment