Skip to Main Content
Learning the Korn Shell, 2nd Edition
book

Learning the Korn Shell, 2nd Edition

by Arnold Robbins, Bill Rosenblatt
April 2002
Beginner content levelBeginner
432 pages
18h 29m
English
O'Reilly Media, Inc.
Content preview from Learning the Korn Shell, 2nd Edition

Chapter 2. Command-Line Editing

It’s always possible to make mistakes when you type at a computer keyboard, but perhaps even more so when you are using a Unix shell. Unix shell syntax is powerful, yet terse, full of odd characters, and not particularly mnemonic, making it possible to construct command lines that are as cryptic as they are complex. The Bourne and C shells exacerbate this situation by giving you extremely limited ways of editing your command lines.

In particular, there is no way to recall a previous command line so that you can fix a mistake. For example, in Chapter 7 we’ll see complex command lines like:

eval cat \$srcname \| ccom \| optimize \| as \> \$objname

If you are an experienced Bourne shell user, undoubtedly you know the frustration of having to retype lines like this. You can use the backspace key to edit, but once you hit ENTER, it’s gone forever!

The C shell provides a small improvement via its history mechanism, which provides a few very awkward ways of editing previous commands. But there are more than a few people who have wondered, “Why can’t I edit my Unix command lines in the same way I can edit text with an editor?”

This is exactly what the Korn shell allows you to do. It has editing modes that allow you to edit command lines with editing commands similar to those of the two most popular Unix editors, vi and Emacs.[18] It also provides a much-extended analogue to the C shell history mechanism called hist (for “history”) ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning the Korn Shell

Learning the Korn Shell

Bill Rosenblatt
Unix Power Tools, 3rd Edition

Unix Power Tools, 3rd Edition

Jerry Peek, Shelley Powers, Tim O'Reilly, Mike Loukides

Publisher Resources

ISBN: 0596001959Supplemental ContentErrata Page