Difficulty: Easy
Correct Answer: cp chap?? progs
Explanation:
Introduction / Context:
Precise filename selection is a daily task in Unix shells. The question tests familiarity with glob wildcards—particularly the question mark, which matches exactly one character—so you can target filenames of a specific pattern without over-matching unintended files.
Given Data / Assumptions:
Concept / Approach:
In shell globs, matches any number of characters (including zero), whereas ? matches exactly one character. Therefore, the pattern for “chap followed by exactly two characters” is chap??. To copy all such files into a destination directory, use cp chap?? progs. This ensures only two-character suffixes are matched and avoids catching longer names that would include.
Step-by-Step Solution:
Verification / Alternative check:
Dry-run with printf '%s\n' chap?? to preview matches. Confirm the destination exists (mkdir -p progs) before executing the copy.
Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:
cp chap?? progs.
Discussion & Comments