Redirections

Redirections allow standard input and outputs to me redirected by the command interpretor.

Interpreter’s input and outputs

Traditionally, every console program is given three files that a referred to as standard output and inputs.

Theses three output can be redirected using pBat. However, cmd.exe allows user to redirect any file descriptor through redirections. But this could lead to absurd results since knowing which descriptor refers to which file. Moreover, this behavior can lead to strange side effects. Thus, this feature is not supported by pBat.

Redirecting input and outputs

pBat uses < and > characters to set redirections. > character is used to redirect stdout and stderr, whereas the < is used to specify stdin redirections.

When pbat encounters either a > or a <, then pBat uses the very first parameter to the right of the same an use it as the name of a file to which the input or output will be redirected. The name of the file and the sign do not have to be separated by any blank character. Then pBat removes the file name from the command line. The > or < signs can be used anywhere in the command line, all of the following lines are valid.

echo >file redirection test
> file echo redirection test
echo redirection test > file

Any of the previous syntax are valid. However, some of them give the code more readability, as such, using the third syntax is highly recommended.

Although the is only one syntax using <, redirections using > are provided with a bunch of different syntaxes, which are the following.

Compatibility

Partially compatible with cmd.exe.

Available since 0.48.

See Also

Command line, Conditionnal operators