Difficulty: Easy
Correct Answer: list of all positional parameters as a single word
Explanation:
Introduction / Context:
Shell scripts receive arguments as positional parameters. Special parameters like $, $@, $#, $?, , and $0 provide structured access to arguments, status codes, and process information. Understanding their semantics is critical for writing reliable scripts and interpreting command-line input.
Given Data / Assumptions:
Concept / Approach:
$* expands to all positional parameters. When double-quoted, "$*" expands to a single word containing all parameters joined by the first character of IFS (often a space). By contrast, "$@" expands to separate words, one per parameter, preserving argument boundaries. Other parameters serve different roles like exit status ($?), process ID (), and script name ($0).
Step-by-Step Solution:
Verification / Alternative check:
In a script invoked as ./s a "b c" d, echo "$" outputs a b c d (one word with embedded spaces as separated by IFS), while echo "$@" outputs a on one field, b c as one field, and d as another, preserving argument boundaries.
Why Other Options Are Wrong:
Common Pitfalls:
Using "$" when you intend to forward arguments verbatim; prefer "$@" in that case to preserve argument separation. Be mindful of IFS changes, which alter how "$" joins arguments.
Final Answer:
list of all positional parameters as a single word
Discussion & Comments