I want to use awk to compare values piped from "df" like so:
df:
Then pull out the red values:
2994040
1200012
And run a comparison:
if 2994040 > 1200012 then:
echo "udev exceeds tmpfs in size"
else echo "udev is smaller than tmpfs in size"
fi
Something like that. I've gotten this far:
I put the above into "colmn" and then ran:
df | ./column which outputs:
1K-blocks
725649232
2994044
1201132
5120
3002824
5487686
I don't know how to grab the values I want, and I don't want to use cut. I want it to be smart enough to read the lines that go with udev or tmpfs (or whatever lines I specify). I imagine that if I can grab the values then I can store them in variables somehow and then run some comparison logic, but I don't know how to put it all together.
Thanks!
df:
Code:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 725649232 118249576 571080120 18% /
udev 2994044 4 [COLOR=#EF2929]2994040[/color] 1% /dev
tmpfs 1201132 1120 [COLOR=#EF2929]1200012[/color] 1% /run
none 5120 0 5120 0% /run/lock
none 3002824 352 3002472 1% /run/shm
/dev/sr0 5487686 5487686 0 100% /media/UDF Volume
Then pull out the red values:
2994040
1200012
And run a comparison:
if 2994040 > 1200012 then:
echo "udev exceeds tmpfs in size"
else echo "udev is smaller than tmpfs in size"
fi
Something like that. I've gotten this far:
Code:
#!/bin/sh
awk '{print $c}' c=${1:-2}
I put the above into "colmn" and then ran:
df | ./column which outputs:
1K-blocks
725649232
2994044
1201132
5120
3002824
5487686
I don't know how to grab the values I want, and I don't want to use cut. I want it to be smart enough to read the lines that go with udev or tmpfs (or whatever lines I specify). I imagine that if I can grab the values then I can store them in variables somehow and then run some comparison logic, but I don't know how to put it all together.
Thanks!