case can determine the range of variable belongs to.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # This script does a very simple test for checking disk space. space=` df -h | awk '{print $5}' | grep % | grep - v Use | sort -n | tail -1 | cut -d "%" -f1 -` case $space in [1-6]*) Message= "All is quiet." ;; [7-8]*) Message= "Start thinking about cleaning out some stuff. There's a partition that is $space % full." ;; 9[1-8]) Message= "Better hurry with that new disk... One partition is $space % full." ;; 99) Message= "I'm drowning here! There's a partition at $space %!" ;; *) Message= "I seem to be running with an nonexistent amount of disk space..." ;; esac echo $Message | mail -s "disk report `date`" anny |
Hide Comments