Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print the value of the variable name.
Bash Scripting
echo [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the dollar sign before the variable name.
Using the variable name without any prefix.
✗ Incorrect
In bash, to access the value of a variable, you use the dollar sign followed by the variable name, like
$name.2fill in blank
mediumComplete the code to print the value of the variable path using braces.
Bash Scripting
echo [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets instead of braces.
Omitting the dollar sign.
✗ Incorrect
Using braces like
${path} helps to clearly mark the variable name, especially when concatenating with other text.3fill in blank
hardFix the error in the code to correctly print the variable file followed by the string .txt.
Bash Scripting
echo [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Writing
$file.txt which looks for variable file.txt.Concatenating without braces causing wrong variable name.
✗ Incorrect
To append text after a variable without confusion, use braces:
${file}.txt ensures only file is treated as the variable.4fill in blank
hardFill both blanks to correctly print the variable user and then the string _data.
Bash Scripting
echo [1][2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using $user_data which looks for variable
user_data.Forgetting to use braces to separate variable and text.
✗ Incorrect
Using
${user} ensures the variable ends before the appended string _data.5fill in blank
hardFill all three blanks to create a variable count with value 5, then print it with braces and add the string items.
Bash Scripting
[1]=5 echo [2][3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using $count without braces when appending text.
Forgetting to assign the variable before printing.
✗ Incorrect
First assign 5 to
count. Then print it with braces ${count} to safely append the string items.