home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Learning the Korn Shell

Learning the Korn ShellSearch this book
Previous: We'd Like to Hear From You Chapter 1 Next: 1.2 Scope of This Book
 

1. Korn Shell Basics

You've used your computer for simple tasks, such as invoking your favorite application programs, reading your electronic mail, and perhaps examining and printing files. You know that your machine runs the UNIX operating system, or maybe you know it under some other name, like SunOS, Ultrix, HP/UX, AIX , A/UX, UTS , or Xenix. But apart from that, you may not have given too much thought to what goes on inside the machine when you type in a command and hit RETURN.

It is true that several layers of events take place whenever you enter a command, but we're going to consider only the top layer, known as the shell . Generically speaking, a shell is any user interface to the UNIX operating system, i.e., any program that takes input from the user, translates it into instructions that the operating system can understand, and conveys the operating system's output back to the user.

There are various types of user interfaces. The Korn shell belongs to the most common category, known as character-based user interfaces. These interfaces accept lines of textual commands that the user types in; they usually produce text-based output. Other types of interfaces include the increasingly common graphical user interfaces (GUI), which add the ability to display arbitrary graphics (not just typewriter characters) and to accept input from mice and other pointing devices, touch-screen interfaces (such as those you see on some bank teller machines), and so on.

1.1 What Is a Shell?

The shell's job, then, is to translate the user's command lines into operating system instructions. For example, consider this command line:

sort -n phonelist > phonelist.sorted

This means, "Sort lines in the file phonelist in numerical order, and put the result in the file phonelist.sorted ." Here's what the shell does with this command:

  1. Breaks up the line into the pieces sort , -n , phonelist , > , and phonelist.sorted . These pieces are called words.

  2. Determines the purpose of the words: sort is a command, -n and phonelist are arguments, and > and phonelist.sorted , taken together, are I/O instructions.

  3. Sets up the I/O according to > phonelist.sorted (output to the file phonelist.sorted ) and some standard, implicit instructions.

  4. Finds the command sort in a file and runs it with the option -n (numerical order) and the argument phonelist (input filename).

Of course, each of these steps really involves several substeps, each of which includes a particular instruction to the underlying operating system.

Remember that the shell itself is not UNIX-just the user interface to it. UNIX is one of the first operating systems to make the user interface independent of the operating system.

Figure 1.1: The shell is a layer around the UNIX operating system

Figure 1.1


Previous: We'd Like to Hear From You Learning the Korn Shell Next: 1.2 Scope of This Book
We'd Like to Hear From You Book Index 1.2 Scope of This Book

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System