Trying a perl script to fetch the % of hard disk usage. [By fetching the 5th column of the 'df -H' output, shows percentage of use].
$thirdlast=`df -H`;
@matches=($thirdlast=~/(\S+%)/g);
print "@matches\n";
Its giving the output.
Use% 3% 1% 1% 0% 1%
Now it is needed to fetch the value if any of these out put goes above 90%. Tried grepping like this.['3' here, '9' in actual script, for 90% to 99% values]
perl script.pl | grep -oh "3\w*"
3
But the problems are:
- This works in terminal but not in script.
- If we grep "9*", value '9' also will be considered right?
What could be done? Any other option other than 'grep'..?