Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print 'Hello, World!' in Bash.
Bash Scripting
echo [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes causes Bash to treat words as separate arguments.
Using single quotes without proper spacing changes the output.
✗ Incorrect
In Bash, to print a string with spaces and punctuation, you must enclose it in quotes. Double quotes allow the string to be printed exactly as is.
2fill in blank
mediumComplete the code to assign the value '5' to a variable named count in Bash.
Bash Scripting
count=[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Adding spaces around '=' causes errors.
Using words instead of numbers changes the variable value.
✗ Incorrect
In Bash, to assign a number to a variable, write the number without spaces or quotes.
3fill in blank
hardFix the error in the code to print the value of the variable name in Bash.
Bash Scripting
echo [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Printing the variable name without $ prints the literal text.
Using single quotes prevents variable expansion.
✗ Incorrect
To print the value of a variable in Bash, prefix it with a dollar sign ($).
4fill in blank
hardFill both blanks to create a loop that prints numbers 1 to 5 in Bash.
Bash Scripting
for i in [1] do echo [2] done
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the list makes it a single string.
Not using $ before the variable prints the variable name.
✗ Incorrect
The loop iterates over the list '1 2 3 4 5'. Inside the loop, $i prints the current number.
5fill in blank
hardFill all three blanks to create a conditional that prints 'Even' for even numbers in Bash.
Bash Scripting
if [ $(( [1] % [2] )) [3] 0 ]; then echo "Even" fi
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '-eq' causes errors in numeric tests.
Using wrong variable names or missing $ in arithmetic.
✗ Incorrect
The expression checks if num modulo 2 equals 0 using -eq for numeric comparison in Bash.