Script to check file system size

Dears,
the output of this command

df -h | tr -s ' ' | cut -f5 -d' '

is

capacity
24%
0%
0%
0%
0%
1%
0%
24%
24%
0%
93%
1%
1%
10%
6%
60%
1%
19%
22%
10%
10%
48%
3%

what i want to do put this out put in if condition there it find 90% send mail to xxx@hotmail.com or something like that

try this methods

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

Output in the mail's body would like:

92%     /var
96%     /data/bla

Hi zaxxon.
i am facing this error when i try to run you code

awk: syntax error near line 1
awk: bailing out near line 1

Could be a problem with the version of awk. If you are using Solaris, you might want to use nawk or /usr/xpg4/bin/awk, or if available gawk.