Command History And Tab Completion - Red Hat ENTERPRISE LINUX 3 - STEP BY STEP GUIDE Manual

Table of Contents

Advertisement

Chapter 3. Shell Prompt Basics
You will probably use the asterisk (
out everything that matches the pattern you are looking for. By typing
ls *.txt
or
ls sn*
you would find
sneakers.txt
The asterisk helps to narrow your search as much as possible.
Another way to narrow a search is to use the question mark symbol (
help locate a file matching a search pattern.
In this case, though,
, you would get
sneaker?.txt
such a file name.
Regular expressions are more complex than the straightforward asterisk or question mark.
When an asterisk, for example, just happens to be part of a file name, as might be the case if the file
was called
sneakers.txt
Using the backslash (
asterisk, but you are instead looking for a file with an asterisk in the name.
If the file is called
sneak*.txt
sneak\*.txt
Here is a brief list of wildcards and regular expressions:
— Matches all characters
*
— Matches one character
?
— Matches the * character
\*
— Matches the ? character
\?
— Matches the ) character
\)

3.11. Command History and Tab Completion

It does not take long before the thought of typing the same command over and over becomes unap-
pealing. One minor typing error can ruin lines of a series of commands.
One solution is to use the command line history. By scrolling with the [Up] and [Down] arrow keys,
you can find plenty of your previously typed commands.
Try it by taking a look again at
time, however, at the shell prompt, type:
cat sneakrs.txt
Nothing happens, of course, because there is no
back the command, then use the [Left Arrow] key to get to the point where we missed the "e." Insert
the letter and press [Enter] again.
We now see the contents of the
) most frequently when you are searching. The asterisk searches
*
and any other files whose name ends with
is useful for matching a single character, so if you were searching for
?
sneakers.txt
, that is when regular expressions can be useful.
sneak*.txt
), you can specify that you do not want to search out everything by using the
\
, type:
sneakers.txt
sneakers.txt
as a result, and/or
(created in Section 3.8.1 Using Redirection). The first
file. Use the [Up Arrow] key to bring
sneakrs.txt
file.
or begins with
.txt
). Like the asterisk, using
?
, if there were
sneakerz.txt
39
.
sn
can
?

Advertisement

Table of Contents
loading

This manual is also suitable for:

Enterprise linux 3

Table of Contents