BASH problem with IS GREATER THAN OR EQUAL TO.
I have tried a dozen variations for this IF statement to work with IS GREATER THAN OR EQUAL TO. My code below WORKS.
array=( $( /usr/bin/sar -q 1 30 |grep Average |awk '{print $2,$3}' ) )
nthreads="${array[0]}"
avproc="${array[1]}"
if [ $nthreads = 1.0 ] && [ $avproc > 5 ]; then
... i will work fine!!
I can not change : if [ $nthreads = 1.0 ] && [ $avproc > 5 ];
to work like if [ $nthreads >= 1 ] && [ $avproc >= 5 ];
I believe part of the problem is the decimal number. But I have tried -gt. I have tried using (( )) expressions. I have attempted to use bc. Many times I get the error 'unary operator expected'.
I have been looking for a few days now and have tried everything I can think of. It seems I have a fundamental problem with how BASH handles variable and data types.
Help appreicated. Thanks