Command Prompt for Windows




Redirecting Command Input and Output

The WinOne® Command Prompt allows Standard Input and Standard Output to be redirected at the command prompt and assumes that Standard Input comes from the keyboard and that Standard Output goes to the screen by default.

The default Standard Input and Standard Output can be redirected using the following characters at the command prompt :-

  • The less than sign ( ie. ' < ' ) to use the contents of a file as the input for a command. For example :-
    SORT < filename
    
  • The greater than sign ( ie. ' > ' ) to send the output from a command to a file. When the specified file does not exist, it is created and when the file does exist, it is over written, and the previous contents are lost. For example :-
    SORT > filename
    
  • The double greater than sign (ie. ' >> ' ) appends the output from a command to the end of a file. For example :-
    SORT >> filename
    
  • The bar character ( ie. ' | ' ) allows the Standard Output from one command to be used as the Standard Input to another command. This is referred to as a pipe. For example :-
    TYPE filename | SORT | MORE
    
    The commands TYPE, SORT and MORE are executed in that order, that is from left to right.

Note:

When using redirection with text mode type programs, the executed task can not be placed in the background. For more information on placing a program in the background see Command Execution and Precedence.

The text format of the redirected input or output is either in ANSI or Unicode text format, depending on the System Option set in the WinOne® Command Prompt. When appending text to an existing text file, the text format will be the same as the existing text file format. The WinOne® Command Prompt will not allow different types of text to be written to the same text file.