1.11 Command-Line Editing

1.11 Command-Line Editing

As you play around with the shell, you may notice that you can edit the command line with the left and right arrow keys, as well as page through previous commands with the up and down arrows. This is as good as standard on almost any Linux system.

However, you should forget about the arrow keys and use control key sequences instead. If you learn and practice the ones listed in Table 1-2, you will have a great advantage when entering text in the many Unix programs that use these standard keystrokes.

Table 1-2: Command-Line Keystrokes

Keystroke

Action

CONTROL-B

Move cursor left

CONTROL-F

Move cursor right

CONTROL-P

View previous command (or move cursor up)

CONTROL-N

View next command (or move cursor down)

CONTROL-A

Move the cursor to the beginning of the line

CONTROL-E

Move the cursor to the end of the line

CONTROL-W

Erase the preceding word

CONTROL-U

Erase the entire line