Полезная информация

Learning the Korn Shell

Learning the Korn ShellSearch this book
Previous: 1.4 Getting the Korn ShellChapter 1
Korn Shell Basics
Next: 1.6 Files

1.5 Interactive Shell Use

When you use the shell interactively, you engage in a login session that begins when you log in and ends when you exit or press [CTRL-D]. [2] During a login session, you type command lines in to the shell; these are lines of text ending in RETURN that you type in to your terminal or workstation. By default, the shell prompts you for each command with a dollar sign, though as you will see in Chapter 3 the prompt can be changed.

[2] You can set up your shell so that it doesn't accept [CTRL-D], i.e., it requires you to type exit to end your session. We recommend this, because [CTRL-D] is too easy to type by accident; see the section on options in Chapter 3.

1.5.1 Commands, Arguments, and Options

Shell command lines consist of one or more words, which are separated on a command line by blanks or TABs. The first word on the line is the command. The rest (if any) are arguments (also called parameters) to the command, which are names of things on which the command will act.

For example, the command line lp myfile consists of the command lp (print a file) and the single argument myfile. lp treats myfile as the name of a file to print. Arguments are often names of files, but not necessarily: in the command line mail billr, the mail program treats billr as the name of the user to which a message will be sent.

An option is a special type of argument that gives the command specific information on what it is supposed to do. Options usually consist of a dash followed by a letter; we say "usually" because this is a convention rather than a hard-and-fast rule. The command lp -h myfile contains the option -h, which tells lp not to print the "banner page" before it prints the file.

Sometimes options take their own arguments. For example, lp -d hp3si -h myfile has two options and one argument. The first option is -d hp3si, which means "Send the output to the printer (destination) called hp3si". The second option and argument are as above.

Previous: 1.4 Getting the Korn ShellLearning the Korn ShellNext: 1.6 Files
1.4 Getting the Korn ShellBook Index1.6 Files

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