../_images/space.png

Kansas State University at Salina

Introduction to Unix

../_images/UNIX_blocks.jpeg

Here DocumentsΒΆ

Linux for Programmers and Users, Section 5.6.2 and 5.17

This rather peculiar metacharacter (<<) allows us to provide complex, multiline input to a command. Perhaps its most common usage is in a shell script used with the cat command to display a lengthy description to the user.

An example might illustrate its usage best:

$ cat << STOP
> Today, we hope that you learn a great deal about Unix.
> We are using Linux as our Unix system.
> There are many versions of Unix systems, including:
>     UNIX, Solaris, BSD, AIX, HP-UX and Linux.
> References to UNIX, as it used to be spelled, are considered
> references to the UNIX from AT&T Bell Labs.  Unix is a
> generic term refering to all Unix like systems.
> STOP
Today, we hope that you learn a great deal about Unix.
We are using Linux as our Unix system.
There are many versions of Unix systems, including:
    UNIX, Solaris, BSD, AIX, HP-UX and Linux.
References to UNIX, as it used to be spelled, are considered
references to the UNIX from AT&T Bell Labs.  Unix is a
generic term refering to all Unix like systems.

In the above example, the > characters at the beginning of each line are produced by the cat command, which is reading from standard input. Those characters will not be present in shell script.

Note

  • The Here Documents metacharacter produced the end-of-file character. It was not necessary to type Cntrl-d above.
  • In the above example, STOP is an identifier. Any string may be used as the terminal string.

Previous topic

Shell Metacharacters

Next topic

The Pipe (|)

This Page