Reading a unix flat file and mailing when PCTUSED is greater than 50%
Posted on 2003-03-12
I am trying to write a shell script that reads the unix flat file and email me those lines only when PCT_USED is greater than 50% and I got stuck. Can anyone please help me ASAP. Thanks in advance!
The flat file format looks like this:
FILESYSTEM ALLOCATED USED FREE PCTUSED MOUNTON
and the following is the script that I started out before I got stuck:
cat unix flat file |while read record
num_col=`echo $record|wc -w`
if [ $num_col -eq 1 ];
if [ -n $record ];
echo $record|read FILESYSTEM ALLOCATED USED FREE PCTUSED MOUNTON
The script works fine upto here and reads the values but then where I go from here, how do you give the condition: [if $PCTUSED -gt 50] then mailx $hostname, $filesystem,$allocated,$used,$free,$pctused,$mounton
Any help is appreciated!