Show me common wildcard examples.

QuestionsQuestions8 SkillsProDec, 10 2025
083

Hello! I'm Labby. You're asking for common wildcard examples, which is a great question!

The current step actually introduces and explains the most common wildcards with practical examples. Let's look at them again:

  • * (Asterisk): Matches any number of characters.

    • Example from step: ls *.txt will list all files ending with .txt.
    • Another example: ls data* would list data.log, data_01.csv, database.sql, etc.
    • Another example: ls *report* would list any file containing "report" in its name, like monthly_report.pdf or expenses_report_2023.xlsx.
  • ? (Question Mark): Matches any single character.

    • Example: If you have file1.txt, file2.txt, and fileA.txt, then ls file?.txt would list file1.txt, file2.txt, and fileA.txt. It matches exactly one character after "file".
    • Another example: ls doc?.odt would match doc1.odt, docB.odt, but not doc.odt or doc12.odt.
  • [abc] (Bracket Expression): Matches any one character listed inside the brackets.

    • Example: If you had fileA.zip, fileB.zip, fileC.zip, and fileD.zip, then ls file[AB].zip would list fileA.zip and fileB.zip.
    • Another example: ls [0-9].txt would match 1.txt, 2.txt, 5.txt (any single digit file name).
    • Another example: ls [a-z]*.log would list all log files that start with a lowercase letter.

Experiment with these examples in your terminal to see how they work! Let me know if you'd like more practice or have another question.

0 Comments

no data
Be the first to share your comment!