0
0
Linux CLIscripting~15 mins

File globbing (wildcards *, ?, []) in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
File globbing with wildcards in Linux CLI
📖 Scenario: You are organizing files in a folder on your Linux system. You want to list files using patterns to find specific groups of files quickly.
🎯 Goal: Learn how to use file globbing with wildcards *, ?, and [] to match files in the command line.
📋 What You'll Learn
Use the ls command with wildcards to list files
Understand how * matches any characters
Understand how ? matches exactly one character
Understand how [] matches any one character inside brackets
💡 Why This Matters
🌍 Real World
File globbing is used daily by system administrators and developers to quickly find, list, or manipulate groups of files without typing each filename.
💼 Career
Knowing how to use wildcards in the command line is essential for tasks like batch renaming, backups, and scripting automation in Linux environments.
Progress0 / 4 steps
1
Create files for testing
Create exactly these files in the current directory using the touch command: file1.txt, file2.txt, fileA.txt, fileB.txt, data1.csv, data2.csv, image1.png, image2.png.
Linux CLI
Need a hint?

Use one touch command with all filenames separated by spaces.

2
Set a pattern variable
Create a variable called pattern and set it to the string file?.txt to match files starting with 'file' followed by exactly one character and ending with '.txt'.
Linux CLI
Need a hint?

Use single quotes around the pattern string.

3
List files matching the pattern
Use the ls command with the variable $pattern to list files matching the pattern file?.txt.
Linux CLI
Need a hint?

Use ls $pattern to expand the variable and list matching files.

4
Output the matched files
Run the script and observe the output. It should list exactly these files: file1.txt, file2.txt, fileA.txt, fileB.txt.
Linux CLI
Need a hint?

The output should show the four files matching the pattern.