Page 100 - 500
P. 100
let you chain programs together so that later ones use the output of
their predecessors as input.
To work together better, many command-line programs follow a
set of conventions that control their interaction.
• By default, programs take all their input as lines of text typed
at the keyboard. But input in the same format also can be
redirected from a file or any device capable of sending lines of
text.
• By default, programs send all their output to the screen as lines
of text. But output in the same format also can be redirected to
a file or another line-oriented device such as a printer.
• Programs are written to set a number called a return value
when they terminate, to indicate the results of the program.
When programs are written according to these rules, you can use
the symbols in Table 1 to control a program's input and output and
to connect or chain programs together.
Table 1. Command Symbols
Symbol Purpose
< Redirects input
> Redirects output
>> Appends redirected output to
existing data
| Pipes output
& Separates multiple commands
in a command line
&& Runs the command after &&
only if the command before && is successful
| | Runs the command after | | only if the
command before | | fails
^ Treats the next symbol as a character
( and ) Groups commands
The Redirection Symbols
As in MS-DOS and UNIX, Command Prompt sessions in
Windows 2000 allow you to override the default source for input
(the keyboard) or the default destination for output (the screen).