|
Straight from the man page for ksh:
Input/Output
Before a command is executed, its input and output may be
redirected using a special notation interpreted by the
shell. The following may appear anywhere in a simple-
command or may precede or follow a command and are not
passed on to the invoked command. Command and parameter
substitution occur before word or digit is used except as
noted below. File name generation occurs only if the pat-
tern matches a single file, and blank interpretation is not
performed.
...
If one of the above is preceded by a digit, then the file
descriptor number referred to 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.
....
The order in which redirections are specified is signifi-
cant. The shell evaluates each redirection in terms of the
(file descriptor, file) association at the time of evalua-
tion. For example:
... 1>fname 2>&1
first associates file descriptor 1 with file fname. It then
associates file descriptor 2 with the file associated with
file descriptor 1 (that is fname). If the order of redirec-
tions were reversed, file descriptor 2 would be associated
with the terminal (assuming file descriptor 1 had been) and
then file descriptor 1 would be associated with file fname.
If a command is followed by & and job control is not active,
then the default standard input for the command is the empty
file /dev/null. Otherwise, the environment for the execu-
tion of a command contains the file descriptors of the
invoking shell as modified by input/output specifications.
|