Bird
0
0

Which of the following is the correct pattern to match files named data1, data2, but not data10?

easy📝 Syntax Q12 of 15
Linux CLI - File and Directory Operations
Which of the following is the correct pattern to match files named data1, data2, but not data10?
A<code>data?</code>
B<code>data*</code>
C<code>data[1-9]</code>
D<code>data??</code>
Step-by-Step Solution
Solution:
  1. Step 1: Understand the pattern data[1-9]

    This matches 'data' followed by exactly one digit from 1 to 9, so it matches 'data1' and 'data2' but not 'data10'.
  2. Step 2: Check other patterns

    data? matches 'data' plus any one character (including letters), data* matches 'data' plus any characters (including 'data10'), and data?? matches 'data' plus exactly two characters (so it matches 'data10').
  3. Final Answer:

    data[1-9] -> Option C
  4. Quick Check:

    Square brackets match one character from set [OK]
Quick Trick: Use [ ] to match one character from a range [OK]
Common Mistakes:
  • Using * which matches too many files
  • Using ? which matches any single character, not range
  • Confusing number of characters matched

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes