.s1 6. The Shell .es For most users, communication with \*sUNIX\*n is carried on with the aid of a program called the Shell. The Shell is a command line interpreter: it reads lines typed by the user and interprets them as requests to execute other programs. In simplest form, a command line consists of the command name followed by arguments to the command, all separated by spaces: .dc command arg\*t\d1\u\*n arg\*t\d2\u\*n .\|.\|. arg\*t\dn\u\*n .ec The Shell splits up the command name and the arguments into separate strings. Then a file with name \fIcommand\fR is sought; \fIcommand\fR may be a path name including the ``/'' character to specify any file in the system. If \fIcommand\fR is found, it is brought into core and executed. The arguments collected by the Shell are accessible to the command. When the command is finished, the Shell resumes its own execution, and indicates its readiness to accept another command by typing a prompt character. .pg If file \fIcommand\fR cannot be found, the Shell prefixes the string \fI/\|bin/\fR to \fIcommand\fR and attempts again to find the file. Directory \fI/\|bin\fR contains all the commands intended to be generally used. .s2 6.1 Standard I/O .es The discussion of I/O in \(sc3 above seems to imply that every file used by a program must be opened or created by the program in order to get a file descriptor for the file. Programs executed by the Shell, however, start off with two open files which have file descriptors 0 and 1. As such a program begins execution, file 1 is open for writing, and is best understood as the standard output file. Except under circumstances indicated below, this file is the user's typewriter. Thus programs which wish to write informative or diagnostic information ordinarily use file descriptor 1. Conversely, file 0 starts off open for reading, and programs which wish to read messages typed by the user usually read this file. .pg The Shell is able to change the standard assignments of these file descriptors from the user's typewriter printer and keyboard. If one of the arguments to a command is prefixed by ``>'', file descriptor 1 will, for the duration of the command, refer to the file named after the ``>''. For example, .dc ls .ec ordinarily lists, on the typewriter, the names of the files in the current directory. The command .dc ls >there .ec creates a file called \fIthere\fR and places the listing there. Thus the argument ``>there'' means, ``place output on \fIthere\fR.'' On the other hand, .dc ed .ec ordinarily enters the editor, which takes requests from the user via his typewriter. The command .dc ed