Hey all,

I am trying to write a shell script that evaluates the size of each user's home directory and if it is greater than 50 MB I want an email to be sent to their user account telling them that they need to reduce the size of their home directory.

I am mainly having trouble with using the output of du -s /home/* to compare each size to 50mb and then sending an email to that user, any help would be fantastic thank you.

du -ks /home/*/ 2>&- | 
  while read s d; do
    u="${d%/}"
    [ "$s" -gt 51200 ] && 
      printf '%s: %d kb\n' "$d" "$s" | 
        mail -s "your home dir is too big ..." "${u#/home/}"
  done