Challenge - 5 Problems
Progress Indicator Pro
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this progress indicator script?
Consider this bash script snippet that simulates a progress bar:
for i in {1..5}; do
echo -n "."
sleep 1
done
echo " Done!"
What will be the output after running this script?Bash Scripting
for i in {1..5}; do echo -n "." sleep 1 done echo " Done!"
Attempts:
2 left
💡 Hint
Look at how echo -n works and how the loop prints dots.
✗ Incorrect
The loop prints a dot without a newline 5 times, then prints ' Done!' on the same line.
📝 Syntax
intermediate2:00remaining
Which option correctly implements a spinner progress indicator in bash?
You want to create a spinner that cycles through | / - \ characters in bash.
Which of these code snippets correctly implements this spinner inside a loop?
Bash Scripting
spinner='|/-\\' for i in {1..4}; do # print spinner character # wait 0.2 seconds # erase spinner character # move to next character sleep 0.2 done
Attempts:
2 left
💡 Hint
Use echo -ne to print without newline and interpret backslash sequences.
✗ Incorrect
Option A uses echo -ne to print spinner char and backspace \b to erase it, correctly cycling spinner.
🔧 Debug
advanced2:00remaining
Why does this progress bar script not update correctly?
This script is supposed to show a progress bar updating from 0% to 100%:
for i in $(seq 0 20 100); do
echo -n "[${i}%]"
sleep 1
done
echo
But it prints all progress states on separate lines instead of updating the same line.
What is the main reason?Attempts:
2 left
💡 Hint
Think about how to overwrite the same line in terminal output.
✗ Incorrect
Without \r, each echo prints after the previous, so progress bar does not overwrite previous output.
🚀 Application
advanced3:00remaining
Which script shows a progress bar with dynamic width based on terminal size?
You want a bash script that shows a progress bar filling from 0% to 100%, adjusting bar width to terminal width.
Which script correctly calculates terminal width and updates the bar accordingly?
Attempts:
2 left
💡 Hint
Calculate filled length as percentage of terminal width.
✗ Incorrect
Option C correctly calculates filled bar length proportional to progress percent and terminal width.
🧠 Conceptual
expert1:30remaining
What is the main benefit of using \r (carriage return) in progress indicators?
In bash scripting, why is the carriage return character \r important when creating progress indicators?
Attempts:
2 left
💡 Hint
Think about how to update progress on the same line without clutter.
✗ Incorrect
Carriage return \r moves cursor to line start so new output overwrites old output, enabling smooth progress updates.