Difficulty: Medium
Correct Answer: patch and catch only
Explanation:
Introduction / Context:
Shell globbing rules in Unix/Linux determine which filenames a pattern expands to before a command runs. Understanding how wildcards interact with hidden files (names that begin with a dot) is essential for predictable results, especially when scripting and batch-processing files. This question explores how the pattern ch behaves with visible and hidden files.
Given Data / Assumptions:
Concept / Approach:
By default, shell globs that do not start with a dot do not match hidden files. The pattern ch matches any filename containing the substring 'ch' anywhere in the name, but it will ignore entries that start with '.' unless the pattern itself begins with '.' or shell options are changed. Therefore, 'patch' and 'catch' match, while '.ch' does not.
Step-by-Step Solution:
Verification / Alternative check:
Run printf '%s\n' ch to preview the shell’s expansion. To include hidden files, you could explicitly write .ch ch or enable dotglob in bash (shopt -s dotglob) and then test again.
Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:
patch and catch only.
Discussion & Comments