Selected Features of the bash Shell
A shell does much more than simply run commands. It also has
powerful features to make this task easier: wildcards for matching
filenames, a “command history” to recall previous commands quickly,
pipes for making the output of one command become the input of
another, variables for storing values for use by the shell, and more.
Take the time to learn these features, and you will become faster and
more productive with Linux. Let’s skim the surface and introduce you
to these useful tools. (For full documentation, run info bash.)
Wildcards
Wildcards are a shorthand for sets of files with similar
names. For example, a* means all
files whose names begin with lowercase “a”. Wildcards are “expanded”
by the shell into the actual set of filenames they match. So if you
type:
$ ls a*
the shell first expands a*
into the filenames that begin with “a” in your current directory, as
if you had typed:
$ ls aardvark adamantium apple
ls never knows you used a
wildcard: it sees only the final list of filenames after the shell
expands the wildcard. Importantly, this means
every Linux command, regardless of its origin,
works with wildcards and other shell features.
Wildcards never match two characters: a leading period, and
the directory slash (/). These
must be given literally, as in .pro* to match .profile, or /etc/*conf to match all filenames ending
in conf in the /etc directory.
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.
Read now
Unlock full access