Difficulty: Medium
Correct Answer: cat emp[!0-9]
Explanation:
Introduction / Context:
Filename expansion (globbing) in POSIX shells lets you select groups of files matching patterns without invoking full regular expressions. Understanding bracket expressions, ranges, and negation is essential for writing concise commands to process batches of files safely and correctly.
Given Data / Assumptions:
Concept / Approach:
Shell globs support bracket lists and negation. Inside [], a leading ! negates the class. [!0-9] therefore matches any single character that is not 0 through 9. Prepending emp makes emp[!0-9], which matches names starting with emp followed by exactly one non-digit. To concatenate contents, use cat with that glob. If the requirement were “one or more” non-digits, you would add a trailing , but the question states a single character.
Step-by-Step Solution:
Verification / Alternative check:
Use printf '%s\n' emp[!0-9] to preview matches safely before concatenating. This confirms the glob resolves to the intended set of filenames.
Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:
cat emp[!0-9].
Discussion & Comments