But, honestly, whenever i see a awk|grep|cut i know there is something deeply amiss. All that grepping and cutting can be done inside awk, but i do not now what your exact df-output is, so it is hard to suggest what the awk-line should exactly look like.
Furthermore, this:
if [[ $archive_capacity > 60% ]]
cannot work: the ">" operator of the test -utility is not understood by all versions of test but even the ones that do only compare integers and "60%" is not an integer - it is a string. You should get rid of the "%" sign when you create the $archive_capacity content and then do like:
if [[ $archive_capacity -gt 60 ]]
first, this is an integer operation and second "-gt" (greater than) is an operator every test will understand.
@bakunin, the [[ ]] compound is not the test command. (But the [ command (that needs ] as its last argument) is test .)
If the shell understands the [[ ]] then it should also understand its > operator: a string comparison.
And here is the problem: [[ 70% > 60% ]] is true but [[ 100% > 60% ]] is false.
While the -gt operator does a number comparison.
A quick-and-dirty trick is to foster a cast to a number:
This is right and i am well aware of the difference between [[...]] (built-in) and [...] ( /bin/test ). Still, the built-in was made to work like (or, at the very least, "similar to") the original test-command and in this specific case there should be no difference. I should have made that thought process clearer, though.
Exactly. Which is why i suggested to get rid of the percent-symbol so that the shell deals with integers instead of strings.
Could I chip in that I prefer to add the -P flag to df in case there are long device or filesystem names that cause the output to split the output on to separate lines.