Results 1 to 2 of 2
ok im writing a bash script that take the snap shot image of df -k awhile back and compairs df -k now. What i need to report is each drive ...
- 11-27-2009 #1Just Joined!
- Join Date
- Sep 2007
- Location
- Ann Arbor, MI
- Posts
- 22
[SOLVED] AWK math???
ok im writing a bash script that take the snap shot image of df -k awhile back and compairs df -k now. What i need to report is each drive over 50% full and an mounts that have grown by 5%.
I seem to have the over 50% full down i just cant seem to get awk to work the math out on the $5 $11 fields i need to sub from or take those two and sub them and see if they are greater than 5%. here is my code:
ive even triedCode:#!/bin/bash df -k > new.df paste old.df new.df | tail +2 >both.df cat both.df | awk '{ if ( $11 > 50 ) print $12,"is over 50 full."}' cat both.df | awk '{ if ($5 < ($11 - 5)) print $12}'Code:cat both.df | awk '{ if (($5 - $11) < -5) print $12}'
please if you can show me why this doesnt work?
thanks,
Joseph Swager
- 11-27-2009 #2Just Joined!
- Join Date
- Sep 2007
- Location
- Ann Arbor, MI
- Posts
- 22
I figured out why the math wasn't working cause it could handle it number then % from the df command so i just add a pipe of tr to translate it out and all works like a charm now.


