FILESYSTEM=/path/subpath
if [ `df -k ${FILESYSTEM} | grep -v Use | awk '{ print $5 }' | sed 's/%//'` -gt 80 ]; then
mailx -s "File System full" mailid@domain.com
fi
The tr does not subsitute anything since a parameter is missing. Also cutting out the percent value without the corresponding file system is useless information in my eyes.
So here another approach:
#!/bin/bash
MAILTO=you@your.org
TMPFILE=/tmp/fs_size123.tmp
THRESHOLD=90
SUBJ="$(uname -n): File system report"
rm -f $TMPFILE > /dev/null 2>&1
df -h|\
awk -v t=$THRESHOLD 'NR>1 {if($5 > t){_[$NF]=$5}} END{for(a in _) printf("%-8s%-s\n", _[a],a)}' > $TMPFILE
if [[ -s $TMPFILE ]]; then
echo $TMPFILE| mail -s "$SUBJ" $MAILTO
fi
exit 0