Check a file size

I'm doing a script thats check if mylogfile.log is bigger then 5000 but i dont know how to write it.
thanks in avance.

find mylogfile.log -size +5K -exec echo 'file larger than 5k' \;
1 Like

what does -exec do ?

if [ $(stat --printf="%s" mylogfile.log ) -gt 5000 ]
then
       echo "File size is greater than 5000"
else
       echo "File size is lesser than 5000"
fi
1 Like

bipinajith always there to help me your the best :smiley:

I need to zip with a path how do i do that.
zip /var/log/mylogfile.log /var/log/mrnet.1.log

Try this :

 ls -ltr mylogfile.log | awk '{if ($5>5000) print $0}'
ls -ltr mylogfile.log | awk  '$5>5000'