Check and compare disk space and email it

I am very new to Linux and learning to script. This is for one of my servers at work that I have to keep track off as far as disk space and how it is used. I have tried to go line by line but little things keep chewing me up. I would appreciate any and all help or advice, and Mutt is installed on the server.

!/bin/bash

#Show the size of the jobs directory and pull the total size

# This just reports the size no matter what

du -hs home/PMjobs> home/reports/DiskUsage.txt
date >> home/reports/DiskUsage.txt

#Show the size of the directory

$FileSize=$(du -hs home/PMjobs | awk {print})

#compares the size of the directory

if [$FileSize -gt 500.0G];

then

# pulls size of additional directories

  cd home/PMjobs
  du -hc PM1 PM2 PM3 PM4 PM5 >> home/reports/DiskUsage.txt
  date >> home/reports/DiskUsage.txt
fi

mutt -s "Disk Usage reports" -a home/reports/DiskUsage.txt admin@anycomp.com 

I modified some of your code,hope to helpful to u.

#! /bin/bash

#you means /home ?
du -hs /home/PMjobs> /home/reports/DiskUsage.txt
date >> /home/reports/DiskUsage.txt


#extract the size number without KB,G,etc...
$FileSize=$(du -hs /home/PMjobs | awk {print $1} | sed 's/G//')

#compares the size of the directory

if [ $FileSize -gt 500.0 ];  #here,no "G"
then

# pulls size of additional directories

cd /home/PMjobs
du -hc PM1 PM2 PM3 PM4 PM5 >> /home/reports/DiskUsage.txt
date >> /home/reports/DiskUsage.txt

fi

mutt -s "Disk Usage reports" -a /home/reports/DiskUsage.txt admin@anycomp.com

du -h will export human readable format ( 14K, 234M, 2.7G). it will generate some issues sometime. for example, if the size is higher than 1000G, you got 1.2T, then your script have issue.

second, define a var to replace the log file which used for several times.

#! /bin/bash

#you means /home ?
LOG=/home/reports/DiskUsage.txt
du -hs /home/PMjobs> $LOG
date >> $LOG

#extract the size number without KB,G,etc...
$FileSize=$(du -ks /home/PMjobs | awk '{print int($1)}')

#compares the size of the directory

if [ $FileSize -gt 500000000.0 ];  #here,no "G"
then

  # pulls size of additional directories

  cd /home/PMjobs
  du -hc PM1 PM2 PM3 PM4 PM5 >> $LOG
  date >> $LOG

fi

mutt -s "Disk Usage reports" -a $LOG admin@anycomp.com

Thanks very much to both of you. I will get this on the server today and see what I can get going.