Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to assign the literal string 'Hello World' to the variable greeting using single quotes.
Bash Scripting
greeting=[1]Hello World[2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using double quotes instead of single quotes changes how variables inside the string are handled.
Forgetting to close the quotes causes syntax errors.
✗ Incorrect
Single quotes in bash preserve the literal value of each character inside them. So to assign a literal string, use single quotes around the text.
2fill in blank
mediumComplete the code to print the literal string $HOME without expanding the variable.
Bash Scripting
echo [1]$HOME[2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using double quotes causes the variable to expand.
Not quoting the string causes the shell to interpret $HOME.
✗ Incorrect
Using single quotes around $HOME prevents the shell from expanding the variable, so it prints the literal text $HOME.
3fill in blank
hardFix the error in the code to assign the string It's sunny to the variable weather using single quotes.
Bash Scripting
weather=[1]It's sunny[2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to put a single quote inside single quotes without escaping.
Using backslash inside single quotes does not work as expected.
✗ Incorrect
Single quotes cannot contain single quote characters inside them. Using double quotes allows the apostrophe inside the string.
4fill in blank
hardFill both blanks to assign the literal string $USER's home is /home/$USER to the variable info using single quotes and double quotes correctly.
Bash Scripting
info=[1]$USER's home is /home/[2]$USER
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using only single quotes causes variables not to expand.
Using only double quotes causes problems with the apostrophe.
✗ Incorrect
Use double quotes to allow variable expansion and include the apostrophe, then use single quotes to prevent expansion for the literal part.
5fill in blank
hardFill both blanks to create a variable path that holds the literal string /home/$USER/Documents using single quotes and variable expansion.
Bash Scripting
path=[1]/home/$USER[2]/Documents
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the whole string in single quotes prevents variable expansion.
Not quoting parts causes syntax errors.
✗ Incorrect
Use single quotes for the literal /home/, then no quotes for $USER to expand it, then double quotes for /Documents to complete the string.