0
0
Bash Scriptingscripting~10 mins

Why variables store and reuse data in Bash Scripting - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to assign the value 'hello' to the variable greeting.

Bash Scripting
greeting=[1]
Drag options to blanks, or click blank then click option'
A'hello'
Bhello
Cgreeting
D"hello"
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning the value without quotes causes errors or unexpected behavior.
Using the variable name as the value instead of the string.
2fill in blank
medium

Complete the code to print the value stored in the variable greeting.

Bash Scripting
echo [1]
Drag options to blanks, or click blank then click option'
A$greeting
B"greeting"
Cgreeting
D'greeting'
Attempts:
3 left
💡 Hint
Common Mistakes
Printing the variable name without $ prints the name, not the value.
Using quotes around the variable name prints it literally.
3fill in blank
hard

Fix the error in the code to correctly assign the value 5 to the variable count.

Bash Scripting
count=[1]
Drag options to blanks, or click blank then click option'
A"5"
B'5'
C5
D$5
Attempts:
3 left
💡 Hint
Common Mistakes
Using $ before a number causes bash to look for a positional parameter.
Putting numbers in quotes is allowed but unnecessary here.
4fill in blank
hard

Fill both blanks to create a variable named name with value 'Alice' and then print it.

Bash Scripting
[1]='Alice'
echo [2]
Drag options to blanks, or click blank then click option'
Aname
BName
C$name
D$Name
Attempts:
3 left
💡 Hint
Common Mistakes
Using $ when assigning a variable causes errors.
Mismatching variable name case between assignment and usage.
5fill in blank
hard

Fill all three blanks to assign 'blue' to color, then assign color to favorite, and finally print favorite.

Bash Scripting
color=[1]
favorite=[2]
echo [3]
Drag options to blanks, or click blank then click option'
A"blue"
B$color
C$favorite
Dblue
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning variables with $ on the left side causes errors.
Forgetting $ when referencing variable values.