next up previous contents index
Next: Path Up: UNIX Shells Previous: UNIX Shells

Entering Commands

When you see the command prompt  you can enter a command  by typing the command name and any options and arguments, followed by a carriage return.gif The default prompts are as follows - % for the C shell, $ for the Korn shell and bash$ for the Bourne Again shell; however, all these may be changed and frequently are.

The basic format of UNIX commands is:

 
               		   command   [-option(s)]   [argument(s)]

Remember, UNIX is case-sensitive and therefore most UNIX commands must be entered in lower case.

The components are separated by at least one blank space. If an argument contains a blank, enclose the argument in double quote marks. Normally, options can be grouped (e.g., the -lw in the example below). Some options can have arguments, and unfortunately there isn't consistency on whether there should be a blank space between the option and its argument.

Examples:

 
               		  wc -lw   file1 file2

wc -l -w file1 file2

f77 -o outputfile program.f

In the third example outputfile is the argument of the option -o.

You should be aware that UNIX commands are not noted for their consistency of format. Furthermore, commands, formats, arguments, and options vary somewhat from one UNIX platform to another. In this Guide, we attempt to be generic and describe options that are widely available; for exact details on any command, including a full list of allowable options and arguments, see the man pages for that command (the man command is described in Section gif). Various options are possible to print man pages on a printer but unfortunately there is no universal formula. You may try one of the following but we cannot guarantee which will work best for you.    

 
               		  man  pwd | col -b | lp -d dest

or groff -man file | lp -d dest

The first command pipes the output of the pwd man pages as an example to be printed on a printer dest. The second command gives a better-formatted output but you require know where the input man pages for the command in question are stored. This will be somewhere in the /usr/man directory hierarchy. You can guess where by looking at the output of man command: the first line will contain the string command(i) and then the file in question should be in /usr/man/mani/ command.1. Note that on some systems, HP-UX for example, the files may only be in /usr/man/mani.Z and need to be uncompressed before used in this way.

To correct typing errors you can use the erase key to erase character-by-character, or the kill key to kill an entire line. Recalling and editing previously-executed commands (command history) depends on the shell you are in and is discussed briefly in a later section.

More than one command can be entered on a line if the commands are separated by semicolons. Such commands will be executed sequentially.

If you need to continue a command to a new line, you can either keep on typing or enter a backslash character followed by a carriage return and then continue on the next line.

You can use parentheses to group commands. Since a subshell is created for each group, this can be used to prevent changing the current environment. It can also be used to redirect all output from a set of commands considered as a group (see below).

Type ahead is permitted, even if the characters get interspersed with output.

UNIX commands are described online via the man command (see section gif for more information).



next up previous contents index
Next: Path Up: UNIX Shells Previous: UNIX Shells



Alan Silverman
Wed Apr 12 16:54:02 METDST 1995