Complete the code to check if the variable num is equal to 10.
if [ "$num" [1] 10 ]; then echo "Number is ten" fi
In bash, to compare integers inside [ ], use -eq for equality.
Complete the code to print "Positive" if the variable num is greater than zero.
if [ "$num" [1] 0 ]; then echo "Positive" fi
-lt which means less than.Use -gt to check if a number is greater than another in bash.
Fix the error in the if statement to correctly check if word equals "hello".
if [[ $word [1] "hello" ]]; then echo "Greeting detected" fi
= inside [[ ]] which is less common and can cause issues.-eq for strings.Inside double brackets [[ ]], use == for string comparison.
Fill both blanks to complete the if-else statement that prints "Even" if num is divisible by 2, else prints "Odd".
if [ $((num [1] 2)) [2] 0 ]; then echo "Even" else echo "Odd" fi
/ instead of modulus %.-ne instead of -eq.Use modulus operator % to get remainder and -eq to check if it equals zero.
Fill all three blanks to create a nested if-else that prints "Positive", "Zero", or "Negative" based on num.
if [ $num [1] 0 ]; then echo "Positive" elif [ $num [2] 0 ]; then echo "Zero" else echo "Negative" fi
Use -gt for greater than zero, -eq for zero, and -lt for less than zero.