Module 2 - test: -ge: unary operator expected

I am using grep and awk to format the output of /proc/meminfo. The line:
if test $totalMemInKB -ge $requiredMemInKB
gives an error “test: -ge: unary operator expected”
I looked up a bit on Stackoverflow and found that it can happen if the variable is being treated as empty however printing it with echo gives the correct value.
The else part of the code where the $totalMemInKB is printed appears to be blank on output.
“Error: Total Memory of KB is insufficient for QBox”

According to your descrioption, variable $totalMemInKB seems to be empty. I doubt it showing correct value while echoing

Please check the variable declaration in Bash Script, and how to assign the value from a grep/awk command, your issue would be solved :slight_smile:


please check this link

Thanks for the reply. The issue was caused by not using backticks for the job