Running Commands from the Shell
computer software
Running Commands from the Shell Running Commands from the Shell
Running Commands from the Shell   Home | Site Map | About Us | Products | Services | News | Contact Us | Links Running Commands from the Shell
Running Commands from the Shell Running Commands from the Shell

Copyright © 2009

Linux® Bible


!?string?
-- Run command containing string. This runs the most recent command that
contains a particular string of characters. For example, you can run the
date
command
again by just searching for part of that command line as follows:
$ !?dat?
date
Thu Oct 26 21:32:41 PDT 2008
Instead of just running a
history
command line immediately, you can recall a particular line and
edit it. You can use the following keys or key combinations to do that, as shown in Table 2-4.
TABLE 2-4
Keystrokes for Using Command History
Key(s)
Function Name
Description
Arrow Keys (
and
)
Step
Press the up and down arrow keys to step through
each command line in your history list to arrive at
the one you want. (Ctrl+P and Ctrl+N do the same
functions, respectively.)
Ctrl+R
Reverse Incremental Search
After you press these keys, you enter a search string
to do a reverse search. As you type the string, a
matching command line appears that you can run
or edit.
Ctrl+S
Forward Incremental Search
Same as the preceding function but for a forward
search.
Alt+P
Reverse Search
After you press these keys, you enter a string to do a
reverse search. Type a string and press Enter to see
the most recent command line that includes that
string.
Alt+N
Forward Search
Same as the preceding function but for a forward
search.
Another way to work with your history list is to use the
fc
command. Type fc followed by a his-
tory line number, and that command line is opened in a text editor. Make the changes that you
want. When you exit the editor, the command runs. You can also give a range of line numbers (for
example,
fc 100 105
). All the commands open in your text editor, and then run one after the
other when you exit the editor.
The history list is stored in the
.bash_history
file in your home directory. Up to 1,000 history
commands are stored for you by default.
53
Running Commands from the Shell
2