ksh.1 (2010 09)
k
ksh(1) ksh(1)
otherwise, the file is truncated to zero length. Note that the
noclobber test is
only applied to regular files, not to named pipes or other file types.
>|word Sames as >, except that it overrides the
noclobber option.
>>word Use file word as standard output. If the file exists, output is appended to it (by first
searching for the end-of-file); otherwise, the file is created.
<>word Open file word for reading and writing as standard input. If the file does not exist
it is created.
<<[ -]word The shell input is read up to a line that matches word, or to an end-of-file. No
parameter 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 char-
acters of the document. Otherwise, parameter and command substitution occurs,
\newline is ignored, and \ must be used to quote the characters
\, $, ‘, and the
first character 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
example:
... 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 com-
mands 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 environ-
ment and creates a parameter for each name found, gives it the corresponding value, and marks it export .
Executed 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
HP-UX 11i Version 3: September 2010 − 9 − Hewlett-Packard Company 9