A cloud developer is writing a shell script to automatically adjust capacity when a usage variable exceeds 80. They tried if [ $usage > 80 ] ; then action, but discovered the script always returns true, even when usage is much lower. Which approach corrects this numeric check?
Enclose the entire condition within parentheses inside brackets
Surround the threshold value with double quotes for integer checks
Use -gt in the condition so the script compares actual numbers
Declare the usage variable as a string and leave the '>' comparison
In many shell environments, using '>' compares strings rather than integers. The -gt symbol compares numeric values properly. By replacing '>' with -gt, the script evaluates the threshold correctly. Other options either rely on string comparisons or do not fix the numeric evaluation.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does '-gt' mean in shell scripting?
Open an interactive chat with Bash
Why does using '>' in shell scripting compare strings instead of numbers?
Open an interactive chat with Bash
How do numeric comparisons work in shell scripts?
Open an interactive chat with Bash
CompTIA Cloud+ CV0-004
Deployment
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access