Practice quoting, redirection, exit status, functions and reliable shell automation through explained scenarios.
Four self-study difficulty levels, from basic concepts to advanced scenarios. Difficulty is an editorial guide, not an official certification ranking. GNU Bash scripting concepts. Examples are for a disposable local test environment; Bash features are not automatically portable to every POSIX shell.
YOUR PRACTICE SPACE
Learn it. Test it. Understand it.
Recognize core concepts and trace a single step.
10 questions in Easy · one answer per question · no timer
Free, no account needed. Answers stay in this tab and reset on reload. This is self-study, not a proctored exam or certificate.
Choose the right challenge
Easy checks core concepts. Medium applies them to tasks. Hard examines edge cases and failure modes. Very advanced combines constraints such as concurrency, security and recovery. Start where you are comfortable; each level has its own attempt and result. These labels are editorial, not certification grades.
What you will learn
Preserve argument boundaries and distinguish data from shell code.
Trace redirections, pipelines, subshells and exit status.
Design explicit error handling and predictable resource cleanup.
Think through a real scenario
A backup script receives a directory containing spaces and sends a producer into a compression pipeline. An unquoted path can become several arguments, and the compressor can succeed after the producer fails. Preserve the path as one quoted argument, inspect pipeline failure explicitly, and publish the output only after the complete operation succeeds. A script finishing without visible output is not proof that the backup is usable.
Turn your result into a study plan
For each missed question, write down the rule you overlooked and test it with a small example. Avoid memorizing an option’s position: understanding the behavior matters more than recognizing the wording. In exam mode explanations stay hidden until you submit; in practice mode use “Check answer” to see feedback immediately.
Read further
The questions and explanations are original EmuPath teaching material. These references provide background for further study; their publishers do not endorse this exam.
Found an ambiguous question? Include the track and question text in your correction report.
Sample Bash Shell Scripting questions with explanations
Preview one question from each difficulty level before choosing a practice session. These examples also appear in the question bank. Try answering first, then open the explanation to check your reasoning.
Easy: Assignments
Which Bash statement assigns the text hello to the variable greeting?
greeting=hello
greeting = hello
set greeting hello
let greeting hello
Show answer and explanation
greeting=hello
A plain assignment has no spaces around its equals sign. Adding spaces makes the shell interpret separate words as a command and arguments.
Medium: Argument forwarding
Which expression forwards all existing positional arguments while preserving each argument boundary?
"$@"
"$*"
$@ without quotes
"$1 $2"
Show answer and explanation
"$@"
Quoted at-sign expansion produces a separate word for each positional parameter. Joining or unquoted expansion can alter boundaries and empty arguments.
Hard: Redirection order
How do command >out 2>&1 and command 2>&1 >out differ?
The first redirects both streams to out; the second leaves stderr at the original stdout destination
Both always redirect both streams to out
The second discards stderr
The first combines only the argument strings
Show answer and explanation
The first redirects both streams to out; the second leaves stderr at the original stdout destination
Redirections are processed from left to right. Duplicating descriptor 1 copies its destination at that point, not any later destination assigned to it.
Very advanced: Error policy
Why is set -e alone insufficient as a complete Bash error-handling strategy?
Its effect depends on syntactic context, and expected failures require deliberate handling
It automatically retries failed commands forever
It validates every output file
It catches all failures in background processes automatically
Show answer and explanation
Its effect depends on syntactic context, and expected failures require deliberate handling
Errexit has documented exceptions in conditions and command lists. Define which failures are expected, check critical results explicitly and handle asynchronous work.