Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to run two commands in a subshell.
Bash Scripting
(echo "Hello" [1] echo "World")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '&&' will run the second command only if the first succeeds.
Using '|' pipes output, not just separates commands.
Using '&' runs commands in background, not sequentially.
✗ Incorrect
Using a semicolon inside parentheses runs both commands sequentially in a subshell.
2fill in blank
mediumComplete the code to capture the output of commands run in a subshell.
Bash Scripting
result=$(echo "Start" [1] echo "End")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '&&' may skip second command if first fails.
Using '|' pipes output, changing what is captured.
Using '&' runs commands in background, output may be lost.
✗ Incorrect
Using a semicolon inside the subshell groups commands and captures combined output.
3fill in blank
hardFix the error in the code to run commands in a subshell and redirect output.
Bash Scripting
(cd /tmp [1] ls) > output.txt Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '&&' may skip 'ls' if 'cd' fails.
Using '|' pipes output, changing behavior.
Using '&' runs commands in background, output redirection may fail.
✗ Incorrect
Using a semicolon correctly separates commands inside the subshell before redirecting output.
4fill in blank
hardFill both blanks to run commands in a subshell and combine outputs.
Bash Scripting
(echo "User:" [1] whoami [2] echo "Done")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '&&' skips commands if previous fails.
Using '|' pipes output, changing flow.
Using '&' runs commands in background, not sequentially.
✗ Incorrect
Semicolons separate commands to run sequentially inside the subshell.
5fill in blank
hardFill all three blanks to create a dictionary-like output with command grouping and condition.
Bash Scripting
output=$( { echo "Start" [1] if [[ -f /etc/passwd ]]; then echo "File exists" [2] else echo "No file"; fi [3] echo "End"; } ) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting semicolons causes syntax errors.
Using '&&' changes flow to conditional execution.
Using '|' pipes output, not suitable here.
✗ Incorrect
Semicolons separate commands and statements inside the grouped commands for proper execution.