Next Previous Contents

2. Lexical Conventions

2.1 Lowercase and Uppercase Letters

In contrast to VMS (but like the C programming language), Unix is case-sensitive. That is, all of the following are regarded as different words by Unix:

        somename
        SOMENAME
        Somename
        SomeName
        sOMENAME

(in fact, with these 8 letters one can create 256 distinct names using case variation alone!)

By convention, virtually all Unix command names and filenames are spelled using lowercase letters. You should therefore avoid using uppercase letters in filenames unless there is a compelling reason to do so (and you must use only lowercase letters in command names, of course.)

Also, you should be aware that if the "SHIFT-LOCK" key on your terminal is in force when you log in, causing you to type your login name and/or password in all uppercase, your login attempt will fail.

2.2 Special Characters

Input Editing Characters

Like VMS, the Unix terminal driver recognizes certain characters for the editing of command input as you type it. Unlike VMS, on Unix systems these are configurable and have impact on other programs such editors, etc. The following should be familiar to VMS users:

RETURN:

enters the current command and causes it to be executed.

DELETE:

deletes the last character typed. On a video terminal, the character is erased from the screen as well.

CTRL-U:

delete the entire current command line. On a video terminal, the line is erased from the screen as well.

Older Unix shells did not have analogues to the other line-editing commands available under VMS (e.g. left, right, up and down arrow, CTRL-E etc.). When using bash (the Bourne-Again Shell), however, these facilities are provided - including the ability to recall command lines not only from the current session, but also from previous sessions as well. (Unlike VMS, Bash maintains a history of the user's previous commands across login sessions.)

Process and Job-Control Characters

Like VMS, Unix treats certain characters typed on the keyboard as a request to interrupt the processing of a command that is already underway. These are:

CTRL-C:

terminates the currently-executing command and returns you to command interpreter (shell) command level.

CTRL-Z:

suspends (but does not terminate) the currently-executing command and returns you to shell command level. Execution of the suspended command may be resumed by using the bg or fg commands, or it may be terminated altogether by the kill command. (See online documentation for bash and these commands if you are interested.) On IRIX systems the CTRL-Z keystroke can suspend some jobs, such as editors, but will not suspend others.

Very important: Beware of pressing CTRL-Z inadvertently, especially while editing a file, since doing so will create a stopped job that must be terminated before you log out. (See discussion below under logging out.)

End-of-file

Like VMS, Unix uses the end-of-file character as a way of terminating certain kinds of input to programs. However, under Unix the end-of-file character is CTRL-D, not CTRL-Z. As noted above, CTRL-Z has a very different meaning, and pressing it inadvertently can cause strange results.

Scrolling Control

Modern computers are fast enough that scrolling control is not too useful -- by the time you activate it, everything that you wanted to see has gone by. However, the following keystrokes can control the scrolling:

CTRL-S:

suspends output to your screen.

CTRL-Q:

resumes output to your screen.

Hint: At any time when a terminal session seems to be frozen, try pressing CTRL-Q to see if the output stream can be unsuspended.

Other Special Characters

A number of other keys have a special meaning to the command interpreter (the shell), including the following:

                * | ; < > ( ) \ ' " `

All of these are described in the manual pages for the shell (bash); however, three are of particular interest because they relate to very powerful Unix facilities known as IO-redirection and piping. (The former has a limited analog in VMS; the latter does not.)

IO-Redirection

For each program run under Unix, the shell establishes two IO streams known as standard input and standard output (by default your keyboard and screen, respectively.) Many commands read data from standard input and/or write to standard output. For example, the ls command lists the names of files in a directory to standard output.

The shell interprets a < followed by a filename in a command line as a request to take standard input from the named file instead of from the keyboard. Likewise, it interprets a > followed by a filename in a command line as a request to send standard output to the named file instead of to the screen.

For example:

ls

would list files in your current default directory to your screen

ls > dirlis

would send the same listing to the file dirlis

Pipelines

In addition to allowing a IO-redirection on a command-line, the shell also allows you to start two or more programs simultaneously, with the output from one becoming the input to the next. This configuration is called a pipeline, and is specified by putting a | between the commands.

For example: the following command will convert a text file coming into it as standard input into a new file on standard output, with each word from the original file appearing on a separate line in the output file (see the manual page on tr for why):

        tr -cs A-Za-z0-9 '\012'

The following command will sort its input file into ascending order, suppressing duplicate entries, and ignoring case distinctions:

        sort -fu

The following pipeline will appear all of the words occurring if file somefile, one to a line in alphabetical order, with each word appearing exactly once:

        tr -cs A-Za-z0-9 '\012' < somefile | sort -fu


Next Previous Contents