Using Wildcards

Wildcards are used on the shell command line to specify files by name or extension. Shells for Linux offer sophisticated forms of wildcards that you can use to perform complex pattern matching. Creating complex wildcards is called building regular expressions.

Building Regular Expressions

Regular expressions are wildcard patterns, built using a special command-line syntax. This syntax uses a number of special characters, some of which are listed in Table 2.2.

Table 2.2. Common Regular Expressions and Characters
Expression Action
* Match all characters
? Match a single character
[a–z] Match a range of characters
[0123] Match a range of characters
\ ? Match the ? character
\ ) Match the ) character
^abc Match pattern ...

Get Practical Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.