Programming Field

‘>>’ (Append redirection) - DOS/Command Prompt Reference

Appends output of the command, specified on the left side of the symbol, to the end of the file, specified on the right side.

Syntax

<command> [<num>]>> <file-name>
<command> [<num>]>>&<num>
<command> Specifies the command line to send output to the file.
<file-name> Specifies the file name for output.
[<num>] [Windows NT series] Specifies the handle number of redirection source. The handle number can be ‘1’ (standard output (STDOUT)) or ‘2’ (standard error (STDERR)), and those output will be redirected. If the handle number is not specified, ‘1’ (STDOUT) will be used.
&<num>

[Windows NT series] Specifies the handle number of redirection target. The handle number can be ‘1’ (standard output (STDOUT)) or ‘2’ (standard error (STDERR)), and output will be written to those target. For example, Echo command usually prints strings to standard output, but if you specify ‘>>&2’ at the end of the command line, you can print strings to standard error.

The above syntaxes are the same as ‘>’.

Details

Usage of ‘>>’

Append redirection is similar to output redirection, but different that append redirection will write the data to the end of the file (not overwrite the file). Append redirection will not reset the file, so if you want to reset, you should use normal output redirection.

Samples

Sample

echo First Line> out.txt
echo Second Line>> out.txt

Make the contents of ‘out.txt’ to ‘First Line(newline)Second Line(newline)’.