Wildcards in Linux commands
Wildcards provides special characters that makes Linux commands so powerful. Since the shell uses filenames so much, it provides special characters to help user rapidly specify groups of filenames.
Wildcards is also known as globbing which allow you to select filenames based on patterns of characters. Wildcards can be used with any command that accepts filenames as arguments The table below lists the wildcards and what they select:
|Matches any characters|
|Matches any single character|
|Matches any characters that is a member of the set characters|
|Matches any characters that is not a member of the set characters|
|Matches any characters that is a member of the specified class|
Below is the commonly used character classes:
|Matches any alphanumeric character|
|Matches any alphabetic character|
|Matches any numeral|
|Matches any lowercase letter|
|Matches any uppercase letter|
Using wildcards makes it possible to construct very sophisticated selection criteria for filenames. Here are some examples of patterns and what they match:
|Any file beginning with "g"|
|Any file beginning with "g" and ending with ".txt"|
|Any file beginning with "Data" followed by exactly three characters|
|All files beginning with either an "a", a "b" or a "c"|
|Any file beginning with "BACKUP." followed by exactly three numerals|
|Any file beginning with an uppercase letter|
|Any file not beginning with a numeral|
|Any file ending with a lowercase letter or the numerals “1”, “2”, or “3”|
If you are coming from another Unix-like environment or have been reading
some other books on this subject, you may have encountered the
[A-Z] or the
[a-z] character range notations. These are traditional Unix notations and
worked in older versions of Linux as well. They can still work, but you have to be
very careful with them because they will not produce the expected results unless
- Dependency injection
- Directives and Pipes
- Data binding
- HTTP Get vs. Post
- Node.js is everywhere
- MongoDB root user
- Prefer Async Script Loading
- Components, Bootstrap and DOM
- What is HEAD in git?
- Show the changes in Git.
- What is AngularJS 2?
- Confidence Interval for a Population Mean
- Accuracy vs. Precision
- Sampling Distribution
- Working with the Normal Distribution
- Standardized score - Z score
- Evaluating the Normal Distribution
- What is Nodejs? Advantages and disadvantage?
- How do I debug Nodejs applications?
- Sync directory search using fs.readdirSync