Installation guide
114 Chapter 11. Shell Prompt Basics
We know the file is called "sneak____.txt," so type:
ls sneak*.txt
and there is the name of the file:
sneakers.txt
You will probably use the asterisk (*) most frequently when you are searching. The asterisk will
search out everything that matches the pattern you are looking for. So even by typing:
ls *.txt
or:
ls sn*
You would find sneakers.txt and any other files whose names begin with sn or ends with .txt. It
helps to narrow your search as much as possible.
One way to narrow a search is to use the question mark symbol (?). Like the asterisk, using ? can help
locate a file matching a search pattern.
In this case, though, ? is useful for matching a single character, so if you were searching for
sneaker?.txt, you would get sneakers.txt as a result, and/or sneakerz.txt, if there were
such a filename.
Regular expressions are more complex than the straightforward asterisk or question mark.
When an asterisk, for example, just happens to be part of a filename, as might be the case if the file
sneakers.txt was called sneak*.txt, that is when regular expressions can be useful.
Using the backslash (\), you can specify that you do not want to search out everything by using the
asterisk, but you are instead looking for a file with an asterisk in the name.
If the file is called sneak*.txt, type:
sneak\*.txt
Here is a brief list of wildcards and regular expressions:
• * — Matches all characters
• ? — Matches one character in a string (such as sneaker?.txt)
• \* — Matches the * character
• \? — Matches the ? character
• \) — Matches the ) character
11.12. Command History and Tab Completion
It does not take long before the thought of typing the same command over and over becomes unap-
pealing, at best. One minor typing error can ruin lines of a command.
One solution is to use the command line history. By scrolling with the [Up Arrow] and [Down Arrow]
keys, you can find plenty of your previously typed commands.
Try it by taking a look again at sneakers.txt (created in Section 11.9.1. The first time, however, at
the shell prompt, type: