0
0
Bash Scriptingscripting~10 mins

Progress indicators 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 print a dot as a progress indicator every second.

Bash Scripting
while true; do echo -n [1]; sleep 1; done
Drag options to blanks, or click blank then click option'
A"#"
B"-"
C"*"
D"."
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the -n option causes newlines instead of a progress line.
Using quotes incorrectly can cause syntax errors.
2fill in blank
medium

Complete the code to show a spinning progress indicator using characters |, /, -, and \.

Bash Scripting
spin='|/-\\'; while true; do for i in $(seq 0 3); do echo -ne "\r${spin:[1]:1}"; sleep 0.2; done; done
Drag options to blanks, or click blank then click option'
Ai
B0
Ci+1
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using i+1 is invalid syntax inside ${} in bash.
Using a fixed number like 0 or 1 will not animate the spinner.
3fill in blank
hard

Fix the error in the code to update a progress bar with hashes (#) and dots (.) correctly.

Bash Scripting
total=10; for ((i=1; i<=total; i++)); do done_part=$(printf '#%.0s' $(seq 1 [1])); left_part=$(printf '.%.0s' $(seq 1 $((total - i)))); echo -ne "[${done_part}${left_part}]\r"; sleep 0.5; done; echo
Drag options to blanks, or click blank then click option'
A1
Btotal
Ci
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using total prints full hashes every time, no progress effect.
Using 0 or 1 prints wrong number of hashes.
4fill in blank
hard

Fill both blanks to create a progress bar that updates with hashes (#) and dots (.) inside brackets.

Bash Scripting
total=20; for ((i=1; i<=total; i++)); do done_part=$(printf '[1]%.0s' $(seq 1 [2])); left_part=$(printf '.%.0s' $(seq 1 $((total - i)))); echo -ne "[${done_part}${left_part}]\r"; sleep 0.3; done; echo
Drag options to blanks, or click blank then click option'
A#
B.
Ci
Dtotal
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the character and count causes wrong output.
Using total instead of i prints full bar every time.
5fill in blank
hard

Fill all three blanks to create a progress bar dictionary in bash using associative arrays, showing keys as steps and values as hashes count.

Bash Scripting
declare -A progress; total=5; for ((i=1; i<=total; i++)); do progress[$ [1] ]=$(printf '[2]%.0s' $(seq 1 [3])); done; for step in "${!progress[@]}"; do echo "$step: ${progress[$step]}"; done
Drag options to blanks, or click blank then click option'
Ai
B#
Dtotal
Attempts:
3 left
💡 Hint
Common Mistakes
Using total as count prints full hashes for all keys.
Using dots (.) instead of hashes (#) changes the progress style.