The usual input source or output destination can be changed, as seen in the following sections.
Send output of cmd to file (overwrite).
Send output of cmd to file (append).
Take input for cmd from file.
The contents of the shell script up to a line identical to text become the standard input for cmd (text can be stored in a shell variable). This command form is sometimes called a Here document. Input is usually typed at the keyboard or in the shell program. Commands that typically use this syntax include cat, ex, and sed. (If <<- is used, leading tabs are stripped from the contents of the here document, and the tabs are ignored when comparing input with the end-of-input text marker.) If any part of text is quoted, the input is passed through verbatim. Otherwise, the contents are processed for variable, command, and arithmetic substitutions.
Supply text of word, with trailing newline, as input to cmd. (This is known as a here string, from the free version of the rc shell.)
Open file for reading and writing on the standard input. The contents are not destroyed.
Send output of cmd to file (overwrite), even if the shell’s noclobber option is set.