diff --git a/doc_src/language.rst b/doc_src/language.rst index b93d7efc5..86d646aec 100644 --- a/doc_src/language.rst +++ b/doc_src/language.rst @@ -160,14 +160,17 @@ Most programs use three input/output (I/O) streams: Each stream has a number called the file descriptor (FD): 0 for stdin, 1 for stdout, and 2 for stderr. -The destination of a stream can be changed using something called *redirection*. For example, ``echo hello > output.txt``, redirects the standard output of the ``echo`` command to a text file. +A stream's destination may be changed with a *redirection*. For example, ``echo hello > output.txt``, redirects the standard output of the ``echo`` command to a text file. -- To read standard input from a file, use ``DESTINATION``. -- To write standard error to a file, use ``2>DESTINATION``. [#]_ -- To append standard output to a file, use ``>>DESTINATION_FILE``. -- To append standard error to a file, use ``2>>DESTINATION_FILE``. -- To not overwrite ("clobber") an existing file, use ``>?DESTINATION`` or ``2>?DESTINATION``. This is known as the "noclobber" redirection. +- ``DESTINATION`` writes standard output to a file. +- ``2>DESTINATION`` writes standard error to a file. [#]_ +- ``>>DESTINATION`` appends standard output to a file. +- ``2>>DESTINATION`` appends standard error to a file. +- ``>?DESTINATION`` writes standard output to a file, or prints an error if the file already exists. +- ``2>?DESTINATION`` writes standard error to a file, or prints an error if the file already exists. + +Append and noclobber combined (like ``>>?``) behaves the same as ``>?``, because new files are initially empty. ``DESTINATION`` can be one of the following: