Bird
0
0

You want to match files named backup_2023-01-01.tar.gz, backup_2023-12-31.tar.gz, but not backup_2022-12-31.tar.gz. Which pattern works?

hard📝 Application Q9 of 15
Linux CLI - File and Directory Operations
You want to match files named backup_2023-01-01.tar.gz, backup_2023-12-31.tar.gz, but not backup_2022-12-31.tar.gz. Which pattern works?
Abackup_202[0-9]-??-??.tar.gz
Bbackup_2023-??-??.tar.gz
Cbackup_202[2-3]-??-??.tar.gz
Dbackup_202?-??-??.tar.gz
Step-by-Step Solution
Solution:
  1. Step 1: Understand pattern parts

    2023 is fixed, ?? matches exactly two characters (digits for month and day).
  2. Step 2: Analyze pattern backup_2023-??-??.tar.gz

    This matches files starting with backup_2023-, then any two characters, dash, any two characters, and ending with .tar.gz.
  3. Step 3: Check other options

    backup_202[0-9]-??-??.tar.gz (A) matches 2020-2029, backup_202?-??-??.tar.gz (B) matches 2020-2029, backup_202[2-3]-??-??.tar.gz (C) matches 2022-2023 including the unwanted backup_2022-12-31.tar.gz.
  4. Final Answer:

    backup_2023-??-??.tar.gz -> Option B
  5. Quick Check:

    Use fixed text plus ? for exact character count [OK]
Quick Trick: Use fixed text plus ? for exact character matches [OK]
Common Mistakes:
MISTAKES
  • Using [] incorrectly for fixed digits
  • Using ? to match variable length
  • Assuming [3] matches digit 3 only

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes