Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the -n option causes newlines instead of a progress line.
Using quotes incorrectly can cause syntax errors.
✗ Incorrect
The code prints a dot (.) without a newline every second to show progress.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
The code uses variable i as the index to get one character from spin string.
3fill in blank
hardFix 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'
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.
✗ Incorrect
The done_part should print i hashes to show progress, so use i as the count.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the character and count causes wrong output.
Using total instead of i prints full bar every time.
✗ Incorrect
The done_part prints i hashes (#) to show progress, so blanks are '#' and 'i'.
5fill in blank
hardFill 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'
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.
✗ Incorrect
The keys are i, the value is i hashes (#), so blanks are i, #, i.