Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print the value of the variable name using double quotes.
Bash Scripting
name="Alice" echo [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes prevents the variable from expanding.
Not using quotes can cause issues if the variable contains spaces.
✗ Incorrect
Using double quotes around "$name" allows the shell to expand the variable and print its value.
2fill in blank
mediumComplete the code to assign the variable greeting a string that includes the variable name expanded inside double quotes.
Bash Scripting
name="Bob" greeting=[1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes causes the variable name to be printed literally.
Not using quotes can cause syntax errors if the string has spaces.
✗ Incorrect
Double quotes around "Hello, $name!" allow the variable
name to expand inside the string.3fill in blank
hardFix the error in the code to correctly print the variable path with spaces using double quotes.
Bash Scripting
path="/home/user/My Documents" echo [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the variable causes the path to split into multiple words.
Using single quotes prevents variable expansion.
✗ Incorrect
Using double quotes around "$path" preserves spaces and expands the variable correctly.
4fill in blank
hardFill both blanks to create a command that prints the variable file with variable expansion and preserves spaces.
Bash Scripting
file="My File.txt" echo [1][2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes prevents variable expansion.
Not quoting the variable causes word splitting.
✗ Incorrect
Double quotes ("{{BLANK_1}}") around the variable ($file) allow expansion and preserve spaces.
5fill in blank
hardFill all three blanks to assign message a string that includes the variable user expanded inside double quotes and an exclamation mark.
Bash Scripting
user="Eve" message=[1]Hello, [2][3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes prevents variable expansion.
Forgetting to close the double quotes causes errors.
✗ Incorrect
Start with a double quote ("), then the variable ($user), and end with an exclamation mark and closing double quote (!").