Recall & Review
beginner
What do single quotes do in bash scripting?
Single quotes preserve the exact text inside them. No variables or special characters are expanded or interpreted.
Click to reveal answer
beginner
How does bash treat variables inside single quotes? For example: 'Hello $USER'
Bash treats everything inside single quotes literally. So '$USER' is not replaced by the username; it stays as the text $USER.
Click to reveal answer
beginner
Which of these strings will print the username in bash?
A) 'Hello $USER'
B) "Hello $USER"
B) "Hello $USER" will print the username because double quotes allow variable expansion. Single quotes do not.
Click to reveal answer
intermediate
Can you include a single quote inside a single-quoted string directly in bash?
No, you cannot directly include a single quote inside single quotes. You must close the quotes, add an escaped single quote, then reopen them.
Click to reveal answer
intermediate
Example: How to print: It's a nice day using single quotes in bash?
Use: echo 'It'\''s a nice day'
This closes the single quote, adds an escaped single quote, then reopens the single quote.
Click to reveal answer
What will this command output? echo 'Today is $DATE'
✗ Incorrect
Single quotes prevent variable expansion, so $DATE is printed literally.
Which quotes allow variable expansion in bash?
✗ Incorrect
Double quotes allow variables to expand, single quotes do not.
How do you include a single quote inside a single-quoted string?
✗ Incorrect
You must close the single quotes, add an escaped single quote, then reopen single quotes.
What does this command print? echo 'Price is $5'
✗ Incorrect
Inside single quotes, backslash is literal, so $ prints as $.
Why use single quotes in bash scripts?
✗ Incorrect
Single quotes keep the text exactly as typed, no expansions or interpretations.
Explain how single quotes affect variable expansion and special characters in bash strings.
Think about how bash treats text inside single quotes compared to double quotes.
You got /3 concepts.
Describe the method to include a single quote character inside a single-quoted string in bash.
Remember you cannot put a single quote directly inside single quotes.
You got /4 concepts.