Page 101 - 500
P. 101

Redirecting Input

                            To  redirect  input  from  a  file,  type  the  command  followed  by  a
                            less-than  sign  (<)  and  the  name  of  the  file.  The  Sort  and  More
                            commands are examples of commands that can accept input from a
                            file. The following example uses Sort to filter the file created with
                            the Dir command shown previously:
                            sort < batch..1st
                            The input file, Batch.lst, contains a list of .bat files followed by a
                            list  of.cmd  files  (assuming  that  you  have  some  of  each  in  the
                            current folder). The output to the screen has the same list of files
                            sorted alphabetically by file name.

                                               Redirecting Output

                            To  redirect  output  to  a  file,  type  the  command  followed  by  a
                            greater-than sign (>) and the name of the file. For example, to send
                            the output of the Dir command to a file rather than the screen, type
                            the following:
                            dir /b *.bat > batch.1st
                            This command line creates a file called Batch.lst that contains the
                            names of all the .bat files in the current folder.
                            Using two greater-than signs (») redirects the output and appends
                            it to an existing file. For example:
                            dir /b *.cmd » batch.1st

                            This command line appends a list of .cmd files to the previously
                            created file containing .bat files. (If you use » to append to a file
                            that doesn't exist, Windows 2000 creates the file.)

                                      Redirecting Input and Output

                            You  can  redirect  both  input  and  output  in  a  command  line.  For
                            example, to use Batch.lst as input to the Sort command and send
                            its output to a file named Sorted.lst, you can type the following:
                            sort  <  batch.1st  >  sorted.1st
   96   97   98   99   100   101   102   103   104   105   106