Skip to Content
Ubuntu: Up and Running
book

Ubuntu: Up and Running

by Robin Nixon
April 2010
Beginner
464 pages
12h 7m
English
O'Reilly Media, Inc.
Content preview from Ubuntu: Up and Running

Wildcards, Sets, and Brace Expansion

We’ve already used wildcards in a few places in this chapter, but there’s a lot more you can do with them than just using the * and ? operators to match strings and characters, respectively, as shown in Table 7-5.

Table 7-5. Wildcards and their meanings

Wildcard

Meaning

*

Any sequence of characters, except for a leading period

?

Any single character, except for a leading period

[set]

Any one of the characters in the set

[ch1-ch2]

Any one of the characters from ch1 through ch2

[^set]

Any single character not in the set

[^ch1-ch2]

Any single character not from ch1 through ch2

{ch,str,etc…}

Match all the characters and/or strings

Using Sets and Ranges

A set of characters placed within a pair of rectangular brackets can match a single character in a file or folder name. This is a more precise version of the ? single-character wildcard. For example, the set [abcdef] will match any of the six characters shown so that [abcdef]ark.txt will match the filenames bark.txt and dark.txt, as long as they both exist. You can also save on typing by using a hyphen to indicate a range of characters so that [a-f] is equivalent to [abcdef].

Another neat thing you can do with a set is force all upper- or all lowercase matches using the ranges [A-Z] or [a-z]. Or you can limit the matching to only alphabetical characters of either case (excluding digits and other characters) by using the set [a-zA-z]. And you can also use numbers in a range, as in [0-9].

Alternatively, you can exclude characters ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ubuntu Made Easy

Ubuntu Made Easy

Rickford Grant, Phil Bull
Ubuntu for Non-Geeks, 4th Edition

Ubuntu for Non-Geeks, 4th Edition

Rickford Grant, Phil Bull

Publisher Resources

ISBN: 9781449382827Errata Page