[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 System User's Guide: Operating System and Devices

Input and Output Redirection in the Bourne Shell

In general, most commands do not know or care whether their input or output is associated with the keyboard, the display screen, or a file. Thus, a command can be used conveniently either at the keyboard or in a pipeline.

The following redirection options can appear anywhere in a simple command. They can also precede or follow a command, but are not passed to the command.

<File Uses the specified file as standard input.
>File Uses the specified file as standard output. Creates the file if it does not exist; otherwise, truncates it to zero length.
> >File Uses the specified file as standard output. Creates the file if it does not exist; otherwise, adds the output to the end of the file.
<<[-]eofstr Reads as standard input all lines from the eofstr variable up to a line containing only eofstr or up to an end-of-file character. If any character in the eofstr variable is quoted, the shell does not expand or interpret any characters in the input lines. Otherwise, it performs variable and command substitution and ignores a quoted new-line character (\new-line). Use a \ (backslash) to quote characters within the eofstr variable or within the input lines.

If you add a - (minus) to the << redirection option, then all leading tabs are stripped from the eofstr variable and from the input lines.

<&Digit Associates standard input with the file descriptor specified by the Digit variable.
>&Digit Associates standard output with the file descriptor specified by the Digit variable.
<&- Closes standard input.
>&- Closes standard output.
Note: The restricted shell does not allow output redirection.

For more information about redirection, see "Input and Output Redirection"

For more information about redirection see Input and Output Redirection


[ Previous | Next | Contents | Glossary | Home | Search ]