HP-UX Reference (11i v3 07/02) - 1 User Commands A-M (vol 1)
k
ksh(1) ksh(1)
<<[ - ]word The shell input is read up to a line that matches word, or to an end-of-file. No param-
eter substitution, command substitution, or file name generation is performed on
word. The resulting document, called a here-document, becomes the standard
input. If any character of word is quoted, no interpretation is placed upon the charac-
ters of the document. Otherwise, parameter and command substitution occurs,
\new-
line is ignored, and
\ must be used to quote the characters
\, $, ‘, and the first char-
acter of word.If
- is appended to
<<, all leading tabs are stripped from word and
from the document.
<&digit The standard input is duplicated from file descriptor digit (see dup(2)).
>&digit The standard output is duplicated to file descriptor digit (see dup(2)).
<&- The standard input is closed.
>&- The standard output is closed.
<&p The input from the co-process is moved to standard input.
>&p The output to the co-process is moved to standard output.
If one of the above is preceded by a digit, the file descriptor number cited is that specified by the digit
(instead of the default 0 or 1). For example:
... 2>&1
means file descriptor 2 is to be opened for writing as a duplicate of file descriptor 1.
Redirection order is significant because the shell evaluates redirections referencing file descriptors in terms
of the currently open file associated with the specified file descriptor at the time of evaluation. For exam-
ple:
... 1>fname 2>&1
first assigns file descriptor 1 (standard output) to file fname, then assigns file descriptor 2 (standard error)
to the file assigned to file descriptor 1; i.e., fname. On the other hand, if the order of redirection is reversed
as follows:
... 2>&1 1>fname
file descriptor 2 is assigned to the current standard output (user terminal unless a different assignment is
inherited). File descriptor 1 is then reassigned to file fname without changing the assignment of file
descriptor 2.
The input and output of a co-process can be moved to a numbered file descriptor allowing other commands
to write to them and read from them using the above redirection operators. If the input of the current co-
process is moved to a numbered file descriptor, another co-process can be started.
If a command is followed by
& and job control is inactive, the default standard input for the command is
the empty file /dev/null. Otherwise, the environment for the execution of a command contains the file
descriptors of the invoking shell as modified by input/output specifications.
Environment
The environment (see environ(5)) is a list of name-value pairs passed to an executed program much like a
normal argument list. The names must be identifiers and the values are character strings.
The shell interacts with the environment in several ways. When invoked, the shell scans the environment
and creates a parameter for each name found, gives it the corresponding value, and marks it export. Exe-
cuted commands inherit the environment. If the user modifies the values of these parameters or creates
new ones by using the
export or typeset -x commands, the values become part of the environment.
The environment seen by any executed command is thus composed of any name-value pairs originally
inherited by the shell whose values can be modified by the current shell, plus any additions which must be
noted in export or typeset -x commands.
The environment for any simple-command or function can be augmented by prefixing it with one or more
parameter assignments. A parameter assignment argument takes the form identifier=value. For example,
TERM=450 cmd args
and
(export TERM; TERM=450; cmd args)
HP-UX 11i Version 3: February 2007 − 9 − Hewlett-Packard Company 497