MPE/iX Shell and Utilities Reference Manual, Vol 2
sh(1) MPE/iX Shell and Utilities sh(1)
number<<[–]name
lets you specify input to a command from your terminal (or from the body of a shell
script). This notation is known as a here document. The shell reads from the standard
input and feeds that as input to file descriptor number until it finds a line that exactly
matches the given name. If you omit number, the default is the standard input. For
example, to process the command
cat <<abc >out
the shell reads input from the terminal until you enter a line that consists of the word
abc. This input is passed as the standard input to the cat command, which then
copies the text to the file
out
.
If any character of name is quoted or escaped, sh does not perform substitutions on
the input; otherwise, it performs variable and command substitutions, respecting the
usual quoting and escape conventions. If you put – before name, sh deletes all lead-
ing tabs in the here document.
number1<&number2
makes the input file descriptor number1 a duplicate of file descriptor number2. If you
omit number1, the default is the standard input (file descriptor 0). For example, <&4
makes the standard input a duplicate of file descriptor 4. In this case, entering input
on 4 has the same effect as entering input on the standard input. A value of p for
number2 stands for the standard output of the current co-process.
number1>&number2
makes the output file descriptor number1 a duplicate of file descriptor number2.If
you omit number1, the default is the standard output (file descriptor 1). For example,
>&2 makes the standard output a duplicate of file descriptor 2 (the standard error). In
this case, writing output on the standard output has the same effect as writing output
on the standard error. A value of p for number2 stands for the standard input of the
current co-process.
number<&–
closes input descriptor number. If you omit number, it closes the standard input.
number>&–
closes output descriptor number. If you omit number, it closes the standard output.
Normally, redirection only applies to the command where the redirection construct appears;
however, see exec(1).
The order of redirection specifications is significant, since an earlier redirection can affect a
later one; however, these specifications may be freely intermixed with other command argu-
ments. Since the shell takes care of the redirection, these constructs are not passed to the
command itself.
Commands and Utilities 1-537