https://drive.google.com/file/d/1T0x669sJXcLtoLT5DcfkiO7A1X-Hvdy-/view?usp=sharing

1. What is Globbing?

Explanation

Globbing (or pathname expansion) is the shell’s way of matching filenames using wildcard characters. The shell expands these patterns into matching filenames before passing them to commands.

⚠️ Important: Globbing is case-sensitive and depends on your system’s locale (language settings).


2. Common Globbing Patterns

Basic Wildcards

Pattern Meaning Example
* Matches zero or more characters File*FileA, File1, FileRR
? Matches exactly one character File?FileA, File1 (not File25)
[...] Matches one character from the set File[AB]FileA, FileB

Examples from Your Notes

# Create test files
touch fileA fileB fileC fileD FileA FileB FileC File1 File2 File3 File25 FileRR Filez5 Filef2

# Test patterns
ls File*          # All files starting with "File"
ls file*          # Only lowercase "file..." (case-sensitive!)
ls *ile*          # Any file containing "ile"
ls f*A            # Starts with "f", ends with "A"
ls File?          # "File" + 1 char: FileA, File1, etc.
ls File??         # "File" + 2 chars: File25, FileRR
ls File[5A]       # "File5" or "FileA"
ls File[BR][a2]   # e.g., FileBa, FileB2, FileRa, FileR2

Lab Steps

  1. Create test files:

    touch fileA fileB FileA File1 File25 FileRR Filez5
    
    
  2. Run each pattern:

    ls File*
    ls File??
    ls File[1A]
    
    

Tips & Warnings


3. Character Ranges and Classes

Ranges