Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if variable x equals 10.
Bash Scripting
if [ "$x" [1] 10 ]; then echo "Equal"; fi
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-ne' which means 'not equal'.
Using '-gt' or '-lt' which check greater or less than.
✗ Incorrect
The operator '-eq' checks if two integers are equal in bash.
2fill in blank
mediumComplete the code to check if variable y is greater than 5.
Bash Scripting
if [ "$y" [1] 5 ]; then echo "Greater"; fi
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-le' which means 'less than or equal'.
Using '-eq' which means 'equal'.
✗ Incorrect
The operator '-gt' means 'greater than' in bash integer comparisons.
3fill in blank
hardFix the error in the code to check if z is less than or equal to 20.
Bash Scripting
if [ "$z" [1] 20 ]; then echo "Less or equal"; fi
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-lt' which means strictly less than.
Using '-ge' which means greater than or equal.
✗ Incorrect
The operator '-le' means 'less than or equal to' in bash integer comparisons.
4fill in blank
hardFill both blanks to check if variable a is not equal to 0 and greater than 10.
Bash Scripting
if [ "$a" [1] 0 ] && [ "$a" [2] 10 ]; then echo "Valid"; fi
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-eq' instead of '-ne' for not equal.
Using '-lt' instead of '-gt' for greater than.
✗ Incorrect
Use '-ne' to check not equal and '-gt' to check greater than.
5fill in blank
hardFill all three blanks to create a condition that checks if b is greater or equal to 5, less than 15, and not equal to 10.
Bash Scripting
if [ "$b" [1] 5 ] && [ "$b" [2] 15 ] && [ "$b" [3] 10 ]; then echo "In range and valid"; fi
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-gt' instead of '-ge' for greater or equal.
Using '-le' instead of '-lt' for less than.
Using '-eq' instead of '-ne' for not equal.
✗ Incorrect
Use '-ge' for greater or equal, '-lt' for less than, and '-ne' for not equal.