Likewise, you can recall a previous command line and change
the elements to make a new command.
By default, the bash shell uses command-line editing that is based on the emacs text editor. (Type
man emacs to read about it, if you care to.) If you are familiar with emacs, you probably already
know most of the keystrokes described here.
If you prefer the vi command for editing shell command lines, you can easily make that
happen. Add the line:
set -o vi
to the .bashrc file in your home directory. The next time you open a shell, you can use vi commands
(as described in the tutorial later in this chapter) to edit your command lines.
To do the editing, you can use a combination of control keys, meta keys, and arrow keys. For
example, Ctrl+F means to hold the Ctrl key and type f. Alt+F means to hold the Alt key and type f.
(Instead of the Alt key, your keyboard may use a Meta key or the Esc key. On a Windows keyboard,
you can use the Windows key.)
To try out a bit of command-line editing, type the following:
$ ls /usr/bin | sort -f | less
This command lists the contents of the /usr/bin directory, sorts the contents in alphabetical
order (regardless of case), and pipes the output to less. The less command displays the first
page of output, after which you can go through the rest of the output a line (press Enter) or a page
(press the spacebar) at a time (type q when you are done).
Pages:
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190