I'm interested in writing a program that will get the size of the mail spool file for the user. (The spool files found in /var/spool/mail/$USER on Linux). To do this, I would like to create a continuous loop that excutes once every 30 seconds. Each time the loop executes, it will compare the size of the mail spool file with its size from the previous loop. If the new size is greater than the old size, I will have it print a message saying "You have new mail."
I've written the script below, but I'm failing to get it to work. Does anyone have any suggestions for me??
while true
do
clear
size= ls -l /var/spool | wc -c
sleep 30
newsize= ls -l /var/spool | wc -c
if [$size < $newsize]
then
echo "You've got mail!"
else
echo "Sorry no mail yet"
fi
sleep 30
done &