08. Globbing and Wildcards *, ?

We can use wildcards to specify some group of characters. For example, suppose we only want the details of the files that have a .html extension.

We can either type:

$ ls -l helloWorld.html
$ ls -l helloWorld2.html
...and so on...

Or...we can use a wildcard, and list all of them in one go!

$ ls -l *.html

The power of the *

The * symbol is known as a wildcard. It stands in place of any text or number, no matter the length. We also have other variables and notations we can use for wildcards:

*
0 or any number of characters.
?
Any one character.
[abc]
The characters a, b, or c.
[!aeiou]
Any non-vowel character.
[a-m]
Characters from a to m (alphabetical).
[2-9]
From number 2 up to 9.

Additionally, we can specify wildcard classes.

[[:alnum:]]
Any alphanumeric character.
[[:alpha:]]
Any alphabet character.
[[:digit:]]
Any numberal.
[[:lower:]]
Any lowercase letter.
[[:upper:]]
Any uppercase letter.

In the next section, we'll see how we can expand these wildcards out to see exactly what they hold.

Aching back from coding all day?

Inversion Therapy Table

Aching back from coding all day? Try Back Problems

Stretch out your back and relieve your back muscles with inversion therapy. This device counteracts the forces of gravity on the body by decompressing and elongating the spine. By using this product just ten minutes a day, you can be well on your way to improved circulation and posture while relieving muscle aches, back pain and stress.

$$ Check price
119.98119.98Amazon 4.5 logo(1,700+ reviews)

More Back Problems resources

Take your Linux skills to the next level!

The Linux Command Line

Take your Linux skills to the next level! Try Linux & UNIX

The Linux Command Line takes you from your very first terminal keystrokes to writing full programs in Bash, the most popular Linux shell. Along the way you'll learn the timeless skills handed down by generations of gray-bearded, mouse-shunning gurus: file navigation, environment configuration, command chaining, pattern matching with regular expressions, and more.

$ Check price
39.9539.95Amazon 4.5 logo(274+ reviews)

More Linux & UNIX resources

Ad