Challenge - 5 Problems
Comment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this commented Bash script?
Consider the following Bash script with comments. What will it print when run?
Bash Scripting
#!/bin/bash # This script prints a greeting echo "Hello, world!" # Print greeting
Attempts:
2 left
💡 Hint
Comments start with # and are ignored by the shell.
✗ Incorrect
The script prints the text inside echo. Comments are ignored and do not print.
📝 Syntax
intermediate1:30remaining
Which option correctly comments out a line in Bash?
In Bash scripting, how do you comment out a single line?
Attempts:
2 left
💡 Hint
Bash uses a special character at the start of the line for comments.
✗ Incorrect
In Bash, the # character starts a comment until the end of the line.
🔧 Debug
advanced2:30remaining
Why does this script print the comment text?
Look at this Bash script:
#!/bin/bash
#echo "Hello"
echo "#Hello"
Why does it print '#Hello' instead of nothing?
Attempts:
2 left
💡 Hint
Think about how quotes affect comments in Bash.
✗ Incorrect
Comments start with # only outside quotes. Inside quotes, # is normal text.
🚀 Application
advanced3:00remaining
Add comments to explain this Bash script
Here is a Bash script:
#!/bin/bash
for i in {1..3}; do
echo "Number $i"
done
Which option shows the script with clear comments added?
Attempts:
2 left
💡 Hint
Good comments explain what each part does clearly.
✗ Incorrect
Option D adds comments before the loop and inside it explaining the purpose clearly.
🧠 Conceptual
expert2:00remaining
What is the purpose of comments in Bash scripts?
Why do we add comments in Bash scripts? Choose the best answer.
Attempts:
2 left
💡 Hint
Think about who reads comments and why.
✗ Incorrect
Comments help people understand the code but do not affect how the script runs.