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. During a login session, you type command lines into the shell; these are lines of text ending in ENTER that you type into 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.
1.5.1. Commands, Arguments, and Options
Shell command lines consist of one or more words, which are separated on a command line by spaces 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 lpr myfile consists of the command lpr (print a file) and the single argument myfile. lpr 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 lpr -h myfile contains the option -h, which tells lpr not to print the "banner page" before it prints the file.
Sometimes options take their own arguments. For example, lpr -P hp3si -h myfile has two options and one argument. The first option is -P hp3si, which means "Send the output to the printer called hp3si." The second option and argument are as above.
1.5.2. Built-in Help
$ cd -? Usage: cd [-LP] [directory] Or: cd [ options ] old new
(You may wish to quote the ?, since, as we will see later, it is special to the shell.) You may also give the --man option to print help in the form of the traditional Unix man page. The output uses ANSI standard escape sequences to produce a visible change on the screen, rendered here using a bold font:
$ cd --man NAME cd - change working directory SYNOPSIS cd [ options ] [directory] cd [ options ] old new DESCRIPTION cd changes the current working directory of the current shell environment. In the first form with one operand, if directory begins with /, or if the first component is . or .., the directory will be changed to this directory. ...
Finally, the --nroff option let's you produce each command's help in the form of nroff -man input. This is convenient for formatting the help for printed output.
For POSIX compliance, a few commands don't accept these options: echo, false, jobs, login, newgrp, true, and :. For test, you have to type test --man -- to get the online help.
Copyright © 2003 O'Reilly & Associates. All rights reserved.