CSE 80 -- Lecture 1 -- Jan 7

This lecture covered class preliminaries -- the first (and only) paper handout, accounts, etc.

Note: the manual page hyperlinks found in this and future class Web pages are to a Web server running on a Web server which, while running Solaris, does not have exactly the same software installed on it as the uAPE machines; furthermore, the search path for commands differ from the default for the uAPE machines, so the manual page displayed for the ls program, for example, is the GNU version of the ls program, not the one found in /usr/bin/ls. The uAPE lab machines does not have the GNU version available at all. The hyperlinks are for your convenience, since most things are identical, but when in doubt, type in $ man ls at your shell prompt to be 100% sure. The GNU software typically implements all of the POSIX standard flags and include extra ones (esp the longname versions introduced with the double dash).

The topics covered are:

  • shells -- command interpreters which takes user input and execute commands based on it. Some of the widely distributed shells are:
  • Bourne shell (7th Edition; /bin/sh)
  • C shell (BSD, 6th Edition shell descendent, but radically changed; /bin/csh)
  • Korn shell (AT&T SysV, a Bourne shell descendant; /usr/bin/ksh)
  • tcsh, zsh (C shell descendants; /software/common/bin/tcsh)
  • bash (Bourne Again shell, a Bourne shell descendant; /software/common/gnu/bin/bash)
  • We will mainly be using bash, since it implements a superset of the POSIX shell standard.
  • Basic command composition methods:
  • Sequencing via the semicolon (;) command terminator.
  • Background execution via the ampersand (&) terminator.
  • Pipes via the vertical bar (|) command separator. A pipe is a fifo queue implemented by the operating system kernel. Typically a pipe has a fixed size of 4 kilobytes.
  • The examples that I used are
    $ ls; echo hi
    for sequencing,
    $ ls & echo hi
    for background execution (of the ls command), and
    $ ls | grep cs30wax
    for a simple pipeline.
  • I/O redirection -- piping is one way to cause I/O redirection to happen, since the standard input of the second command (e.g., the grep) comes from the read or output end of a pipe, and the standard output of the first command (e.g., the ls command) comes from the write or input end of the pipe. Other I/O redirection methods are:
  • output redirection via the greater than symbol (>), which connects the standard output of a command to a file (first truncating the file).
  • output redirection via the double greater than symbol (>>), which connects the standard output of a command to the end of a file, appending new data to an existing file (if the file did not exist already, it would be created).
  • input redirection via the less than symbol (<), which connects the standard input of a command to the top of a file.
  • A more-or-less equivalent sequence of commands to ls | grep cs30wax is
    $ ls > ls.out
    $ grep cs30wax < ls.out
  • I mentioned in class that the output of $ ls and $ ls | more (or even $ ls | cat look different. Why?

    I mentioned in class that the more command is also special, since it reads the terminal for a prompt. How does it do that?

    [ CSE 80 | ACS home | CSE home | CSE calendar | bsy's home page ]
    picture of bsy

    bsy@cse.ucsd.edu, last updated Tue Mar 18 15:49:21 PST 1997.

    email bsy