Challenge - 5 Problems
Double Quotes Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this Bash script?
Consider the following Bash script:
What will be printed when this script runs?
name=World echo "Hello $name!" echo 'Hello $name!'
What will be printed when this script runs?
Bash Scripting
name=World echo "Hello $name!" echo 'Hello $name!'
Attempts:
2 left
💡 Hint
Remember that double quotes allow variable expansion, but single quotes do not.
✗ Incorrect
In Bash, variables inside double quotes are replaced by their values. Inside single quotes, variables are treated as literal text.
💻 Command Output
intermediate2:00remaining
What does this script print?
Given this Bash script:
What is the output?
var=5 echo "$var is a number" echo '$var is a number'
What is the output?
Bash Scripting
var=5 echo "$var is a number" echo '$var is a number'
Attempts:
2 left
💡 Hint
Check how variables behave inside double vs single quotes.
✗ Incorrect
Double quotes expand variables, so $var becomes 5. Single quotes print the text as-is.
🔧 Debug
advanced2:00remaining
Why does this script not print the variable value?
Look at this Bash script:
Why does it print '$greeting, friend!' instead of 'Hello, friend!'?
greeting=Hello echo '$greeting, friend!'
Why does it print '$greeting, friend!' instead of 'Hello, friend!'?
Bash Scripting
greeting=Hello
echo '$greeting, friend!'Attempts:
2 left
💡 Hint
Try changing single quotes to double quotes.
✗ Incorrect
Single quotes in Bash treat everything inside as literal text, so variables are not expanded.
💻 Command Output
advanced2:00remaining
What is the output of this script with mixed quotes?
Consider this Bash script:
What will be printed?
user=Alice echo "User is '$user'" echo 'User is "$user"'
What will be printed?
Bash Scripting
user=Alice echo "User is '$user'" echo 'User is "$user"'
Attempts:
2 left
💡 Hint
Remember how quotes inside quotes affect variable expansion.
✗ Incorrect
Inside double quotes, single quotes are literal, so $user expands. Inside single quotes, double quotes and variables are literal.
🚀 Application
expert2:00remaining
How many items are in the array after this script runs?
Given this Bash script:
What number will be printed?
items="apple banana cherry"
arr=($items)
echo ${#arr[@]}What number will be printed?
Bash Scripting
items="apple banana cherry" arr=($items) echo ${#arr[@]}
Attempts:
2 left
💡 Hint
Check how the string is split into array elements.
✗ Incorrect
The string is split by spaces into three elements: apple, banana, cherry. So the array length is 3.