0
0
Bash Scriptingscripting~10 mins

Single quotes (literal strings) in Bash Scripting - Interactive Code Practice

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

Complete 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'
A'
B"
C`
D\
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.
2fill in blank
medium

Complete 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'
A'
B"
C`
Attempts:
3 left
💡 Hint
Common Mistakes
Using double quotes causes the variable to expand.
Not quoting the string causes the shell to interpret $HOME.
3fill in blank
hard

Fix 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'
A'
B"
C\'
D`
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.
4fill in blank
hard

Fill 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'
A"
B'
C$
D\
Attempts:
3 left
💡 Hint
Common Mistakes
Using only single quotes causes variables not to expand.
Using only double quotes causes problems with the apostrophe.
5fill in blank
hard

Fill 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'
A"
D'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the whole string in single quotes prevents variable expansion.
Not quoting parts causes syntax errors.