Saving Output

The output of a command-line program usually prints out in the Command Prompt window. You can save output by redirecting it into a file, using the > character. For example, the command

dir >listing.txt

lists the files in the current directory, and stores the results in the file listing.txt. You could then type notepad listing.txt to view the results. By itself, > creates a new file or replaces an existing file. You can tack output onto the end of (append to) a file using >>, as in this example:

dir c:\windows >>listing.txt

You can also send the output of one program to another program using | (the pipe character), as in

dir c:\windows | findstr /i setup

which lists the contents of folder c:\windows and prints out only entries that ...

Get Windows 8 In Depth now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.